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.

tgsi.rst 20KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271
  1. TGSI
  2. ====
  3. TGSI, Tungsten Graphics Shader Infrastructure, is an intermediate language
  4. for describing shaders. Since Gallium is inherently shaderful, shaders are
  5. an important part of the API. TGSI is the only intermediate representation
  6. used by all drivers.
  7. Instruction Set
  8. ---------------
  9. From GL_NV_vertex_program
  10. ^^^^^^^^^^^^^^^^^^^^^^^^^
  11. ARL - Address Register Load
  12. .. math::
  13. dst.x = \lfloor src.x\rfloor
  14. dst.y = \lfloor src.y\rfloor
  15. dst.z = \lfloor src.z\rfloor
  16. dst.w = \lfloor src.w\rfloor
  17. MOV - Move
  18. .. math::
  19. dst.x = src.x
  20. dst.y = src.y
  21. dst.z = src.z
  22. dst.w = src.w
  23. LIT - Light Coefficients
  24. .. math::
  25. dst.x = 1
  26. dst.y = max(src.x, 0)
  27. dst.z = (src.x > 0) ? max(src.y, 0)^{clamp(src.w, -128, 128))} : 0
  28. dst.w = 1
  29. RCP - Reciprocal
  30. .. math::
  31. dst.x = \frac{1}{src.x}
  32. dst.y = \frac{1}{src.x}
  33. dst.z = \frac{1}{src.x}
  34. dst.w = \frac{1}{src.x}
  35. RSQ - Reciprocal Square Root
  36. .. math::
  37. dst.x = \frac{1}{\sqrt{|src.x|}}
  38. dst.y = \frac{1}{\sqrt{|src.x|}}
  39. dst.z = \frac{1}{\sqrt{|src.x|}}
  40. dst.w = \frac{1}{\sqrt{|src.x|}}
  41. EXP - Approximate Exponential Base 2
  42. .. math::
  43. dst.x = 2^{\lfloor src.x\rfloor}
  44. dst.y = src.x - \lfloor src.x\rfloor
  45. dst.z = 2^{src.x}
  46. dst.w = 1
  47. LOG - Approximate Logarithm Base 2
  48. .. math::
  49. dst.x = \lfloor\log_2{|src.x|}\rfloor
  50. dst.y = \frac{|src.x|}{2^{\lfloor\log_2{|src.x|}\rfloor}}
  51. dst.z = \log_2{|src.x|}
  52. dst.w = 1
  53. MUL - Multiply
  54. .. math::
  55. dst.x = src0.x \times src1.x
  56. dst.y = src0.y \times src1.y
  57. dst.z = src0.z \times src1.z
  58. dst.w = src0.w \times src1.w
  59. ADD - Add
  60. .. math::
  61. dst.x = src0.x + src1.x
  62. dst.y = src0.y + src1.y
  63. dst.z = src0.z + src1.z
  64. dst.w = src0.w + src1.w
  65. DP3 - 3-component Dot Product
  66. .. math::
  67. dst.x = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
  68. dst.y = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
  69. dst.z = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
  70. dst.w = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z
  71. DP4 - 4-component Dot Product
  72. .. math::
  73. dst.x = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
  74. dst.y = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
  75. dst.z = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
  76. dst.w = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src0.w \times src1.w
  77. DST - Distance Vector
  78. .. math::
  79. dst.x = 1
  80. dst.y = src0.y \times src1.y
  81. dst.z = src0.z
  82. dst.w = src1.w
  83. MIN - Minimum
  84. .. math::
  85. dst.x = min(src0.x, src1.x)
  86. dst.y = min(src0.y, src1.y)
  87. dst.z = min(src0.z, src1.z)
  88. dst.w = min(src0.w, src1.w)
  89. MAX - Maximum
  90. .. math::
  91. dst.x = max(src0.x, src1.x)
  92. dst.y = max(src0.y, src1.y)
  93. dst.z = max(src0.z, src1.z)
  94. dst.w = max(src0.w, src1.w)
  95. SLT - Set On Less Than
  96. .. math::
  97. dst.x = (src0.x < src1.x) ? 1 : 0
  98. dst.y = (src0.y < src1.y) ? 1 : 0
  99. dst.z = (src0.z < src1.z) ? 1 : 0
  100. dst.w = (src0.w < src1.w) ? 1 : 0
  101. SGE - Set On Greater Equal Than
  102. .. math::
  103. dst.x = (src0.x >= src1.x) ? 1 : 0
  104. dst.y = (src0.y >= src1.y) ? 1 : 0
  105. dst.z = (src0.z >= src1.z) ? 1 : 0
  106. dst.w = (src0.w >= src1.w) ? 1 : 0
  107. MAD - Multiply And Add
  108. .. math::
  109. dst.x = src0.x \times src1.x + src2.x
  110. dst.y = src0.y \times src1.y + src2.y
  111. dst.z = src0.z \times src1.z + src2.z
  112. dst.w = src0.w \times src1.w + src2.w
  113. SUB - Subtract
  114. .. math::
  115. dst.x = src0.x - src1.x
  116. dst.y = src0.y - src1.y
  117. dst.z = src0.z - src1.z
  118. dst.w = src0.w - src1.w
  119. LRP - Linear Interpolate
  120. .. math::
  121. dst.x = src0.x \times src1.x + (1 - src0.x) \times src2.x
  122. dst.y = src0.y \times src1.y + (1 - src0.y) \times src2.y
  123. dst.z = src0.z \times src1.z + (1 - src0.z) \times src2.z
  124. dst.w = src0.w \times src1.w + (1 - src0.w) \times src2.w
  125. CND - Condition
  126. .. math::
  127. dst.x = (src2.x > 0.5) ? src0.x : src1.x
  128. dst.y = (src2.y > 0.5) ? src0.y : src1.y
  129. dst.z = (src2.z > 0.5) ? src0.z : src1.z
  130. dst.w = (src2.w > 0.5) ? src0.w : src1.w
  131. DP2A - 2-component Dot Product And Add
  132. .. math::
  133. dst.x = src0.x \times src1.x + src0.y \times src1.y + src2.x
  134. dst.y = src0.x \times src1.x + src0.y \times src1.y + src2.x
  135. dst.z = src0.x \times src1.x + src0.y \times src1.y + src2.x
  136. dst.w = src0.x \times src1.x + src0.y \times src1.y + src2.x
  137. FRAC - Fraction
  138. .. math::
  139. dst.x = src.x - \lfloor src.x\rfloor
  140. dst.y = src.y - \lfloor src.y\rfloor
  141. dst.z = src.z - \lfloor src.z\rfloor
  142. dst.w = src.w - \lfloor src.w\rfloor
  143. CLAMP - Clamp
  144. .. math::
  145. dst.x = clamp(src0.x, src1.x, src2.x)
  146. dst.y = clamp(src0.y, src1.y, src2.y)
  147. dst.z = clamp(src0.z, src1.z, src2.z)
  148. dst.w = clamp(src0.w, src1.w, src2.w)
  149. FLR - Floor
  150. This is identical to ARL.
  151. .. math::
  152. dst.x = \lfloor src.x\rfloor
  153. dst.y = \lfloor src.y\rfloor
  154. dst.z = \lfloor src.z\rfloor
  155. dst.w = \lfloor src.w\rfloor
  156. ROUND - Round
  157. .. math::
  158. dst.x = round(src.x)
  159. dst.y = round(src.y)
  160. dst.z = round(src.z)
  161. dst.w = round(src.w)
  162. EX2 - Exponential Base 2
  163. .. math::
  164. dst.x = 2^{src.x}
  165. dst.y = 2^{src.x}
  166. dst.z = 2^{src.x}
  167. dst.w = 2^{src.x}
  168. LG2 - Logarithm Base 2
  169. .. math::
  170. dst.x = \log_2{src.x}
  171. dst.y = \log_2{src.x}
  172. dst.z = \log_2{src.x}
  173. dst.w = \log_2{src.x}
  174. POW - Power
  175. .. math::
  176. dst.x = src0.x^{src1.x}
  177. dst.y = src0.x^{src1.x}
  178. dst.z = src0.x^{src1.x}
  179. dst.w = src0.x^{src1.x}
  180. XPD - Cross Product
  181. .. math::
  182. dst.x = src0.y \times src1.z - src1.y \times src0.z
  183. dst.y = src0.z \times src1.x - src1.z \times src0.x
  184. dst.z = src0.x \times src1.y - src1.x \times src0.y
  185. dst.w = 1
  186. ABS - Absolute
  187. .. math::
  188. dst.x = |src.x|
  189. dst.y = |src.y|
  190. dst.z = |src.z|
  191. dst.w = |src.w|
  192. RCC - Reciprocal Clamped
  193. XXX cleanup on aisle three
  194. .. math::
  195. dst.x = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
  196. dst.y = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
  197. dst.z = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
  198. dst.w = (1 / src.x) > 0 ? clamp(1 / src.x, 5.42101e-020, 1.884467e+019) : clamp(1 / src.x, -1.884467e+019, -5.42101e-020)
  199. DPH - Homogeneous Dot Product
  200. .. math::
  201. dst.x = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
  202. dst.y = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
  203. dst.z = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
  204. dst.w = src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z + src1.w
  205. COS - Cosine
  206. .. math::
  207. dst.x = \cos{src.x}
  208. dst.y = \cos{src.x}
  209. dst.z = \cos{src.x}
  210. dst.w = \cos{src.x}
  211. DDX - Derivative Relative To X
  212. .. math::
  213. dst.x = partialx(src.x)
  214. dst.y = partialx(src.y)
  215. dst.z = partialx(src.z)
  216. dst.w = partialx(src.w)
  217. DDY - Derivative Relative To Y
  218. .. math::
  219. dst.x = partialy(src.x)
  220. dst.y = partialy(src.y)
  221. dst.z = partialy(src.z)
  222. dst.w = partialy(src.w)
  223. KILP - Predicated Discard
  224. discard
  225. PK2H - Pack Two 16-bit Floats
  226. TBD
  227. PK2US - Pack Two Unsigned 16-bit Scalars
  228. TBD
  229. PK4B - Pack Four Signed 8-bit Scalars
  230. TBD
  231. PK4UB - Pack Four Unsigned 8-bit Scalars
  232. TBD
  233. RFL - Reflection Vector
  234. .. math::
  235. dst.x = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.x - src1.x
  236. dst.y = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.y - src1.y
  237. dst.z = 2 \times (src0.x \times src1.x + src0.y \times src1.y + src0.z \times src1.z) / (src0.x \times src0.x + src0.y \times src0.y + src0.z \times src0.z) \times src0.z - src1.z
  238. dst.w = 1
  239. Considered for removal.
  240. SEQ - Set On Equal
  241. .. math::
  242. dst.x = (src0.x == src1.x) ? 1 : 0
  243. dst.y = (src0.y == src1.y) ? 1 : 0
  244. dst.z = (src0.z == src1.z) ? 1 : 0
  245. dst.w = (src0.w == src1.w) ? 1 : 0
  246. SFL - Set On False
  247. .. math::
  248. dst.x = 0
  249. dst.y = 0
  250. dst.z = 0
  251. dst.w = 0
  252. Considered for removal.
  253. SGT - Set On Greater Than
  254. .. math::
  255. dst.x = (src0.x > src1.x) ? 1 : 0
  256. dst.y = (src0.y > src1.y) ? 1 : 0
  257. dst.z = (src0.z > src1.z) ? 1 : 0
  258. dst.w = (src0.w > src1.w) ? 1 : 0
  259. SIN - Sine
  260. .. math::
  261. dst.x = \sin{src.x}
  262. dst.y = \sin{src.x}
  263. dst.z = \sin{src.x}
  264. dst.w = \sin{src.x}
  265. SLE - Set On Less Equal Than
  266. .. math::
  267. dst.x = (src0.x <= src1.x) ? 1 : 0
  268. dst.y = (src0.y <= src1.y) ? 1 : 0
  269. dst.z = (src0.z <= src1.z) ? 1 : 0
  270. dst.w = (src0.w <= src1.w) ? 1 : 0
  271. SNE - Set On Not Equal
  272. .. math::
  273. dst.x = (src0.x != src1.x) ? 1 : 0
  274. dst.y = (src0.y != src1.y) ? 1 : 0
  275. dst.z = (src0.z != src1.z) ? 1 : 0
  276. dst.w = (src0.w != src1.w) ? 1 : 0
  277. STR - Set On True
  278. .. math::
  279. dst.x = 1
  280. dst.y = 1
  281. dst.z = 1
  282. dst.w = 1
  283. TEX - Texture Lookup
  284. TBD
  285. TXD - Texture Lookup with Derivatives
  286. TBD
  287. TXP - Projective Texture Lookup
  288. TBD
  289. UP2H - Unpack Two 16-Bit Floats
  290. TBD
  291. Considered for removal.
  292. UP2US - Unpack Two Unsigned 16-Bit Scalars
  293. TBD
  294. Considered for removal.
  295. UP4B - Unpack Four Signed 8-Bit Values
  296. TBD
  297. Considered for removal.
  298. UP4UB - Unpack Four Unsigned 8-Bit Scalars
  299. TBD
  300. Considered for removal.
  301. X2D - 2D Coordinate Transformation
  302. .. math::
  303. dst.x = src0.x + src1.x \times src2.x + src1.y \times src2.y
  304. dst.y = src0.y + src1.x \times src2.z + src1.y \times src2.w
  305. dst.z = src0.x + src1.x \times src2.x + src1.y \times src2.y
  306. dst.w = src0.y + src1.x \times src2.z + src1.y \times src2.w
  307. Considered for removal.
  308. From GL_NV_vertex_program2
  309. ^^^^^^^^^^^^^^^^^^^^^^^^^^
  310. ARA - Address Register Add
  311. TBD
  312. Considered for removal.
  313. ARR - Address Register Load With Round
  314. .. math::
  315. dst.x = round(src.x)
  316. dst.y = round(src.y)
  317. dst.z = round(src.z)
  318. dst.w = round(src.w)
  319. BRA - Branch
  320. pc = target
  321. Considered for removal.
  322. CAL - Subroutine Call
  323. push(pc)
  324. pc = target
  325. RET - Subroutine Call Return
  326. pc = pop()
  327. Potential restrictions:
  328. * Only occurs at end of function.
  329. SSG - Set Sign
  330. .. math::
  331. dst.x = (src.x > 0) ? 1 : (src.x < 0) ? -1 : 0
  332. dst.y = (src.y > 0) ? 1 : (src.y < 0) ? -1 : 0
  333. dst.z = (src.z > 0) ? 1 : (src.z < 0) ? -1 : 0
  334. dst.w = (src.w > 0) ? 1 : (src.w < 0) ? -1 : 0
  335. CMP - Compare
  336. .. math::
  337. dst.x = (src0.x < 0) ? src1.x : src2.x
  338. dst.y = (src0.y < 0) ? src1.y : src2.y
  339. dst.z = (src0.z < 0) ? src1.z : src2.z
  340. dst.w = (src0.w < 0) ? src1.w : src2.w
  341. KIL - Conditional Discard
  342. .. math::
  343. if (src.x < 0 || src.y < 0 || src.z < 0 || src.w < 0)
  344. discard
  345. endif
  346. SCS - Sine Cosine
  347. .. math::
  348. dst.x = \cos{src.x}
  349. dst.y = \sin{src.x}
  350. dst.z = 0
  351. dst.y = 1
  352. TXB - Texture Lookup With Bias
  353. TBD
  354. NRM - 3-component Vector Normalise
  355. .. math::
  356. dst.x = src.x / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
  357. dst.y = src.y / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
  358. dst.z = src.z / (src.x \times src.x + src.y \times src.y + src.z \times src.z)
  359. dst.w = 1
  360. DIV - Divide
  361. .. math::
  362. dst.x = \frac{src0.x}{src1.x}
  363. dst.y = \frac{src0.y}{src1.y}
  364. dst.z = \frac{src0.z}{src1.z}
  365. dst.w = \frac{src0.w}{src1.w}
  366. DP2 - 2-component Dot Product
  367. .. math::
  368. dst.x = src0.x \times src1.x + src0.y \times src1.y
  369. dst.y = src0.x \times src1.x + src0.y \times src1.y
  370. dst.z = src0.x \times src1.x + src0.y \times src1.y
  371. dst.w = src0.x \times src1.x + src0.y \times src1.y
  372. TXL - Texture Lookup With LOD
  373. TBD
  374. BRK - Break
  375. TBD
  376. IF - If
  377. TBD
  378. BGNFOR - Begin a For-Loop
  379. dst.x = floor(src.x)
  380. dst.y = floor(src.y)
  381. dst.z = floor(src.z)
  382. if (dst.y <= 0)
  383. pc = [matching ENDFOR] + 1
  384. endif
  385. Note: The destination must be a loop register.
  386. The source must be a constant register.
  387. Considered for cleanup / removal.
  388. REP - Repeat
  389. TBD
  390. ELSE - Else
  391. TBD
  392. ENDIF - End If
  393. TBD
  394. ENDFOR - End a For-Loop
  395. dst.x = dst.x + dst.z
  396. dst.y = dst.y - 1.0
  397. if (dst.y > 0)
  398. pc = [matching BGNFOR instruction] + 1
  399. endif
  400. Note: The destination must be a loop register.
  401. Considered for cleanup / removal.
  402. ENDREP - End Repeat
  403. TBD
  404. PUSHA - Push Address Register On Stack
  405. push(src.x)
  406. push(src.y)
  407. push(src.z)
  408. push(src.w)
  409. Considered for cleanup / removal.
  410. POPA - Pop Address Register From Stack
  411. dst.w = pop()
  412. dst.z = pop()
  413. dst.y = pop()
  414. dst.x = pop()
  415. Considered for cleanup / removal.
  416. From GL_NV_gpu_program4
  417. ^^^^^^^^^^^^^^^^^^^^^^^^
  418. Support for these opcodes indicated by a special pipe capability bit (TBD).
  419. CEIL - Ceiling
  420. .. math::
  421. dst.x = \lceil src.x\rceil
  422. dst.y = \lceil src.y\rceil
  423. dst.z = \lceil src.z\rceil
  424. dst.w = \lceil src.w\rceil
  425. I2F - Integer To Float
  426. .. math::
  427. dst.x = (float) src.x
  428. dst.y = (float) src.y
  429. dst.z = (float) src.z
  430. dst.w = (float) src.w
  431. NOT - Bitwise Not
  432. .. math::
  433. dst.x = ~src.x
  434. dst.y = ~src.y
  435. dst.z = ~src.z
  436. dst.w = ~src.w
  437. TRUNC - Truncate
  438. XXX how is this different from floor?
  439. .. math::
  440. dst.x = trunc(src.x)
  441. dst.y = trunc(src.y)
  442. dst.z = trunc(src.z)
  443. dst.w = trunc(src.w)
  444. SHL - Shift Left
  445. .. math::
  446. dst.x = src0.x << src1.x
  447. dst.y = src0.y << src1.x
  448. dst.z = src0.z << src1.x
  449. dst.w = src0.w << src1.x
  450. SHR - Shift Right
  451. .. math::
  452. dst.x = src0.x >> src1.x
  453. dst.y = src0.y >> src1.x
  454. dst.z = src0.z >> src1.x
  455. dst.w = src0.w >> src1.x
  456. AND - Bitwise And
  457. .. math::
  458. dst.x = src0.x & src1.x
  459. dst.y = src0.y & src1.y
  460. dst.z = src0.z & src1.z
  461. dst.w = src0.w & src1.w
  462. OR - Bitwise Or
  463. .. math::
  464. dst.x = src0.x | src1.x
  465. dst.y = src0.y | src1.y
  466. dst.z = src0.z | src1.z
  467. dst.w = src0.w | src1.w
  468. MOD - Modulus
  469. .. math::
  470. dst.x = src0.x \bmod src1.x
  471. dst.y = src0.y \bmod src1.y
  472. dst.z = src0.z \bmod src1.z
  473. dst.w = src0.w \bmod src1.w
  474. XOR - Bitwise Xor
  475. .. math::
  476. dst.x = src0.x ^ src1.x
  477. dst.y = src0.y ^ src1.y
  478. dst.z = src0.z ^ src1.z
  479. dst.w = src0.w ^ src1.w
  480. SAD - Sum Of Absolute Differences
  481. .. math::
  482. dst.x = |src0.x - src1.x| + src2.x
  483. dst.y = |src0.y - src1.y| + src2.y
  484. dst.z = |src0.z - src1.z| + src2.z
  485. dst.w = |src0.w - src1.w| + src2.w
  486. TXF - Texel Fetch
  487. TBD
  488. TXQ - Texture Size Query
  489. TBD
  490. CONT - Continue
  491. TBD
  492. From GL_NV_geometry_program4
  493. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  494. EMIT - Emit
  495. TBD
  496. ENDPRIM - End Primitive
  497. TBD
  498. From GLSL
  499. ^^^^^^^^^^
  500. BGNLOOP - Begin a Loop
  501. TBD
  502. BGNSUB - Begin Subroutine
  503. TBD
  504. ENDLOOP - End a Loop
  505. TBD
  506. ENDSUB - End Subroutine
  507. TBD
  508. NOP - No Operation
  509. Do nothing.
  510. NRM4 - 4-component Vector Normalise
  511. .. math::
  512. dst.x = \frac{src.x}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
  513. dst.y = \frac{src.y}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
  514. dst.z = \frac{src.z}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
  515. dst.w = \frac{src.w}{src.x \times src.x + src.y \times src.y + src.z \times src.z + src.w \times src.w}
  516. ps_2_x
  517. ^^^^^^^^^^^^
  518. CALLNZ - Subroutine Call If Not Zero
  519. TBD
  520. IFC - If
  521. TBD
  522. BREAKC - Break Conditional
  523. TBD
  524. Explanation of symbols used
  525. ------------------------------
  526. Functions
  527. ^^^^^^^^^^^^^^
  528. :math:`|x|` Absolute value of `x`.
  529. :math:`\lceil x \rceil` Ceiling of `x`.
  530. clamp(x,y,z) Clamp x between y and z.
  531. (x < y) ? y : (x > z) ? z : x
  532. :math:`\lfloor x\rfloor` Floor of `x`.
  533. :math:`\log_2{x}` Logarithm of `x`, base 2.
  534. max(x,y) Maximum of x and y.
  535. (x > y) ? x : y
  536. min(x,y) Minimum of x and y.
  537. (x < y) ? x : y
  538. partialx(x) Derivative of x relative to fragment's X.
  539. partialy(x) Derivative of x relative to fragment's Y.
  540. pop() Pop from stack.
  541. :math:`x^y` `x` to the power `y`.
  542. push(x) Push x on stack.
  543. round(x) Round x.
  544. trunc(x) Truncate x.
  545. Keywords
  546. ^^^^^^^^^^^^^
  547. discard Discard fragment.
  548. dst First destination register.
  549. dst0 First destination register.
  550. pc Program counter.
  551. src First source register.
  552. src0 First source register.
  553. src1 Second source register.
  554. src2 Third source register.
  555. target Label of target instruction.
  556. Other tokens
  557. ---------------
  558. Declaration Semantic
  559. ^^^^^^^^^^^^^^^^^^^^^^^^
  560. Follows Declaration token if Semantic bit is set.
  561. Since its purpose is to link a shader with other stages of the pipeline,
  562. it is valid to follow only those Declaration tokens that declare a register
  563. either in INPUT or OUTPUT file.
  564. SemanticName field contains the semantic name of the register being declared.
  565. There is no default value.
  566. SemanticIndex is an optional subscript that can be used to distinguish
  567. different register declarations with the same semantic name. The default value
  568. is 0.
  569. The meanings of the individual semantic names are explained in the following
  570. sections.
  571. TGSI_SEMANTIC_POSITION
  572. """"""""""""""""""""""
  573. Position, sometimes known as HPOS or WPOS for historical reasons, is the
  574. location of the vertex in space, in ``(x, y, z, w)`` format. ``x``, ``y``, and ``z``
  575. are the Cartesian coordinates, and ``w`` is the homogenous coordinate and used
  576. for the perspective divide, if enabled.
  577. As a vertex shader output, position should be scaled to the viewport. When
  578. used in fragment shaders, position will ---
  579. XXX --- wait a minute. Should position be in [0,1] for x and y?
  580. XXX additionally, is there a way to configure the perspective divide? it's
  581. accelerated on most chipsets AFAIK...
  582. Position, if not specified, usually defaults to ``(0, 0, 0, 1)``, and can
  583. be partially specified as ``(x, y, 0, 1)`` or ``(x, y, z, 1)``.
  584. XXX usually? can we solidify that?
  585. TGSI_SEMANTIC_COLOR
  586. """""""""""""""""""
  587. Colors are used to, well, color the primitives. Colors are always in
  588. ``(r, g, b, a)`` format.
  589. If alpha is not specified, it defaults to 1.
  590. TGSI_SEMANTIC_BCOLOR
  591. """"""""""""""""""""
  592. Back-facing colors are only used for back-facing polygons, and are only valid
  593. in vertex shader outputs. After rasterization, all polygons are front-facing
  594. and COLOR and BCOLOR end up occupying the same slots in the fragment, so
  595. all BCOLORs effectively become regular COLORs in the fragment shader.
  596. TGSI_SEMANTIC_FOG
  597. """""""""""""""""
  598. The fog coordinate historically has been used to replace the depth coordinate
  599. for generation of fog in dedicated fog blocks. Gallium, however, does not use
  600. dedicated fog acceleration, placing it entirely in the fragment shader
  601. instead.
  602. The fog coordinate should be written in ``(f, 0, 0, 1)`` format. Only the first
  603. component matters when writing from the vertex shader; the driver will ensure
  604. that the coordinate is in this format when used as a fragment shader input.
  605. TGSI_SEMANTIC_PSIZE
  606. """""""""""""""""""
  607. PSIZE, or point size, is used to specify point sizes per-vertex. It should
  608. be in ``(p, n, x, f)`` format, where ``p`` is the point size, ``n`` is the minimum
  609. size, ``x`` is the maximum size, and ``f`` is the fade threshold.
  610. XXX this is arb_vp. is this what we actually do? should double-check...
  611. When using this semantic, be sure to set the appropriate state in the
  612. :ref:`rasterizer` first.
  613. TGSI_SEMANTIC_GENERIC
  614. """""""""""""""""""""
  615. Generic semantics are nearly always used for texture coordinate attributes,
  616. in ``(s, t, r, q)`` format. ``t`` and ``r`` may be unused for certain kinds
  617. of lookups, and ``q`` is the level-of-detail bias for biased sampling.
  618. These attributes are called "generic" because they may be used for anything
  619. else, including parameters, texture generation information, or anything that
  620. can be stored inside a four-component vector.
  621. TGSI_SEMANTIC_NORMAL
  622. """"""""""""""""""""
  623. XXX no clue.
  624. TGSI_SEMANTIC_FACE
  625. """"""""""""""""""
  626. FACE is the facing bit, to store the facing information for the fragment
  627. shader. ``(f, 0, 0, 1)`` is the format. The first component will be positive
  628. when the fragment is front-facing, and negative when the component is
  629. back-facing.
  630. TGSI_SEMANTIC_EDGEFLAG
  631. """"""""""""""""""""""
  632. XXX no clue