Clone of mesa.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615
  1. $ /*
  2. $ Shader test script.
  3. $
  4. $ Author: Michal Krol
  5. $
  6. $ Comment line starts with dollar sign and white space.
  7. $
  8. $ $program <name> starts a new test program section called <name>. Contains all other sections.
  9. $
  10. $ $attrib <name> starts vertex data input section for attrib called <name>. Each line consists of
  11. $ four values that form single vertex attrib.
  12. $
  13. $ $vertex starts vertex shader section. Contains $code and &output sections.
  14. $
  15. $ $code starts source code section. All text in this section gets compiled into appropriate
  16. $ shader object.
  17. $
  18. $ $output starts shader execution results section. These are compared, value-by-value,
  19. $ with results of executing printMESA() functions within a shader.
  20. $ */
  21. $ /*
  22. $ --------------------------------------------------------------------------------------------------
  23. $ Test printMESA() function.
  24. $ */
  25. $program PRINT TEST
  26. $vertex
  27. $code
  28. #version 110
  29. #extension MESA_shader_debug: require
  30. void main () {
  31. gl_Position = gl_ModelViewMatrix * gl_Vertex;
  32. gl_FrontColor = vec4 (1.0);
  33. printMESA (11.1);
  34. printMESA (111);
  35. printMESA (true);
  36. printMESA (vec2 (22.1, 22.2));
  37. printMESA (vec3 (33.1, 33.2, 33.3));
  38. printMESA (vec4 (44.1, 44.2, 44.3, 44.4));
  39. printMESA (ivec2 (221, 222));
  40. printMESA (ivec3 (331, 332, 333));
  41. printMESA (ivec4 (441, 442, 443, 444));
  42. printMESA (bvec2 (false, true));
  43. printMESA (bvec3 (true, true, false));
  44. printMESA (bvec4 (true, false, true, false));
  45. printMESA (mat2 (55.11, 55.12, 55.21, 55.22));
  46. printMESA (mat3 (66.11, 66.12, 66.13,
  47. 66.21, 66.22, 66.23,
  48. 66.31, 66.32, 66.33));
  49. printMESA (mat4 (77.11, 77.12, 77.13, 77.14,
  50. 77.21, 77.22, 77.23, 77.24,
  51. 77.31, 77.32, 77.33, 77.34,
  52. 77.41, 77.42, 77.43, 77.44));
  53. }
  54. $output
  55. 11.1
  56. 111
  57. true
  58. 22.1
  59. 22.2
  60. 33.1
  61. 33.2
  62. 33.3
  63. 44.1
  64. 44.2
  65. 44.3
  66. 44.4
  67. 221
  68. 222
  69. 331
  70. 332
  71. 333
  72. 441
  73. 442
  74. 443
  75. 444
  76. false
  77. true
  78. true
  79. true
  80. false
  81. true
  82. false
  83. true
  84. false
  85. 55.11
  86. 55.12
  87. 55.21
  88. 55.22
  89. 66.11
  90. 66.12
  91. 66.13
  92. 66.21
  93. 66.22
  94. 66.23
  95. 66.31
  96. 66.32
  97. 66.33
  98. 77.11
  99. 77.12
  100. 77.13
  101. 77.14
  102. 77.21
  103. 77.22
  104. 77.23
  105. 77.24
  106. 77.31
  107. 77.32
  108. 77.33
  109. 77.34
  110. 77.41
  111. 77.42
  112. 77.43
  113. 77.44
  114. $ /*
  115. $ --------------------------------------------------------------------------------------------------
  116. $ Test type casting.
  117. $ */
  118. $program TYPE CAST TEST
  119. $attrib gl_Vertex
  120. 0.0 0.0 0.0 1.0
  121. $attrib _Zero
  122. 0.0 0.0 0.0 0.0
  123. $attrib _One
  124. 1.1 0.0 0.0 0.0
  125. $attrib _Two
  126. 2.2 0.0 0.0 0.0
  127. $attrib _MinusThree
  128. -3.3 0.0 0.0 0.0
  129. $vertex
  130. $code
  131. #version 110
  132. #extension MESA_shader_debug: require
  133. attribute float _Zero;
  134. attribute float _One;
  135. attribute float _Two;
  136. attribute float _MinusThree;
  137. void main () {
  138. gl_Position = gl_ModelViewMatrix * gl_Vertex;
  139. gl_FrontColor = vec4 (1.0);
  140. printMESA (_Zero);
  141. printMESA (_One);
  142. printMESA (_Two);
  143. printMESA (_MinusThree);
  144. printMESA (float (_Zero));
  145. printMESA (float (_One));
  146. printMESA (float (_Two));
  147. printMESA (float (_MinusThree));
  148. printMESA (float (45.99));
  149. printMESA (float (-6.17));
  150. printMESA (bool (_Zero));
  151. printMESA (bool (_One));
  152. printMESA (bool (_Two));
  153. printMESA (bool (_MinusThree));
  154. printMESA (bool (45.99));
  155. printMESA (bool (-6.17));
  156. printMESA (bool (0.0001));
  157. printMESA (bool (0.0));
  158. printMESA (int (_Zero));
  159. printMESA (int (_One));
  160. printMESA (int (_Two));
  161. printMESA (int (_MinusThree));
  162. printMESA (int (45.99));
  163. printMESA (int (45.22));
  164. printMESA (int (-6.17));
  165. printMESA (int (-6.87));
  166. }
  167. $output
  168. 0.0
  169. 1.1
  170. 2.2
  171. -3.3
  172. 0.0
  173. 1.1
  174. 2.2
  175. -3.3
  176. 45.99
  177. -6.17
  178. false
  179. true
  180. true
  181. true
  182. true
  183. true
  184. true
  185. false
  186. 0
  187. 1
  188. 2
  189. -3
  190. 45
  191. 45
  192. -6
  193. -6
  194. $ /*
  195. $ --------------------------------------------------------------------------------------------------
  196. $ Test vector swizzles.
  197. $ */
  198. $program SWIZZLE TEST
  199. $attrib gl_Vertex
  200. 0.0 0.0 0.0 1.0
  201. $attrib _One
  202. 1.1 1.2 1.3 1.4
  203. $attrib _Two
  204. 2.1 2.2 2.3 2.4
  205. $vertex
  206. $code
  207. #version 110
  208. #extension MESA_shader_debug: require
  209. attribute vec4 _One;
  210. attribute vec4 _Two;
  211. void assign5678 (out vec4 v)
  212. {
  213. v.x = 5.5;
  214. v.y = 6.6;
  215. v.z = 7.7;
  216. v.w = 8.8;
  217. }
  218. void main () {
  219. gl_Position = gl_ModelViewMatrix * gl_Vertex;
  220. gl_FrontColor = vec4 (1.0);
  221. printMESA (_One);
  222. printMESA (_Two);
  223. printMESA (_One.x);
  224. printMESA (_One.y);
  225. printMESA (_One.z);
  226. printMESA (_One.w);
  227. printMESA (_Two.xy);
  228. printMESA (_Two.yx);
  229. printMESA (_Two.xw);
  230. printMESA (_Two.wx);
  231. printMESA (_Two.yz);
  232. printMESA (_Two.zy);
  233. printMESA (_Two.xz);
  234. printMESA (_Two.zx);
  235. printMESA (_Two.zw);
  236. printMESA (_Two.wz);
  237. printMESA (_One.xyz);
  238. printMESA (_One.yzx);
  239. printMESA (_One.zxy);
  240. printMESA (_One.xzy);
  241. printMESA (_One.yzw);
  242. printMESA (_One.zwx);
  243. printMESA (_Two.xyzw);
  244. printMESA (_Two.yzwx);
  245. printMESA (_Two.wzyx);
  246. printMESA (_Two.zwyx);
  247. printMESA (_One.xx);
  248. printMESA (_One.zz);
  249. printMESA (_One.ww);
  250. printMESA (_Two.xxx);
  251. printMESA (_Two.yyy);
  252. printMESA (_Two.www);
  253. printMESA (_One.xxxx);
  254. printMESA (_One.zzzz);
  255. printMESA (_Two.xxyy);
  256. printMESA (_Two.wwxx);
  257. printMESA (_Two.zxxw);
  258. vec4 v;
  259. v.zxwy = vec4 (5.5, 6.6, 7.7, 8.8);
  260. printMESA (v);
  261. assign5678 (v.ywxz);
  262. printMESA (v);
  263. }
  264. $output
  265. 1.1
  266. 1.2
  267. 1.3
  268. 1.4
  269. 2.1
  270. 2.2
  271. 2.3
  272. 2.4
  273. 1.1
  274. 1.2
  275. 1.3
  276. 1.4
  277. 2.1
  278. 2.2
  279. 2.2
  280. 2.1
  281. 2.1
  282. 2.4
  283. 2.4
  284. 2.1
  285. 2.2
  286. 2.3
  287. 2.3
  288. 2.2
  289. 2.1
  290. 2.3
  291. 2.3
  292. 2.1
  293. 2.3
  294. 2.4
  295. 2.4
  296. 2.3
  297. 1.1
  298. 1.2
  299. 1.3
  300. 1.2
  301. 1.3
  302. 1.1
  303. 1.3
  304. 1.1
  305. 1.2
  306. 1.1
  307. 1.3
  308. 1.2
  309. 1.2
  310. 1.3
  311. 1.4
  312. 1.3
  313. 1.4
  314. 1.1
  315. 2.1
  316. 2.2
  317. 2.3
  318. 2.4
  319. 2.2
  320. 2.3
  321. 2.4
  322. 2.1
  323. 2.4
  324. 2.3
  325. 2.2
  326. 2.1
  327. 2.3
  328. 2.4
  329. 2.2
  330. 2.1
  331. 1.1
  332. 1.1
  333. 1.3
  334. 1.3
  335. 1.4
  336. 1.4
  337. 2.1
  338. 2.1
  339. 2.1
  340. 2.2
  341. 2.2
  342. 2.2
  343. 2.4
  344. 2.4
  345. 2.4
  346. 1.1
  347. 1.1
  348. 1.1
  349. 1.1
  350. 1.3
  351. 1.3
  352. 1.3
  353. 1.3
  354. 2.1
  355. 2.1
  356. 2.2
  357. 2.2
  358. 2.4
  359. 2.4
  360. 2.1
  361. 2.1
  362. 2.3
  363. 2.1
  364. 2.1
  365. 2.4
  366. 6.6
  367. 8.8
  368. 5.5
  369. 7.7
  370. 7.7
  371. 5.5
  372. 8.8
  373. 6.6
  374. $ /*
  375. $ --------------------------------------------------------------------------------------------------
  376. $ Test relational operators.
  377. $ */
  378. $program RELATIONAL OPERATOR TEST
  379. $attrib gl_Vertex
  380. 0.0 0.0 0.0 1.0
  381. $attrib _Two
  382. 2.0 0.0 0.0 0.0
  383. $attrib _Two2
  384. 2.0 0.0 0.0 0.0
  385. $attrib _MinusThree
  386. -3.0 0.0 0.0 0.0
  387. $vertex
  388. $code
  389. #version 110
  390. #extension MESA_shader_debug: require
  391. attribute float _Two;
  392. attribute float _Two2;
  393. attribute float _MinusThree;
  394. struct foo
  395. {
  396. float f;
  397. vec4 v4;
  398. vec3 v3;
  399. mat4 m4;
  400. int i;
  401. bool b;
  402. };
  403. void printMESA (const in foo bar)
  404. {
  405. printMESA (bar.f);
  406. printMESA (bar.v4);
  407. printMESA (bar.v3);
  408. printMESA (bar.m4);
  409. printMESA (bar.i);
  410. printMESA (bar.b);
  411. }
  412. void main () {
  413. gl_Position = gl_ModelViewMatrix * gl_Vertex;
  414. gl_FrontColor = vec4 (1.0);
  415. int iTwo = int (_Two);
  416. int iTwo2 = int (_Two2);
  417. int iMinusThree = int (_MinusThree);
  418. printMESA (_Two <= _Two);
  419. printMESA (_Two <= _Two2);
  420. printMESA (_Two <= _MinusThree);
  421. printMESA (_MinusThree <= _Two);
  422. printMESA (iTwo <= iTwo);
  423. printMESA (iTwo <= iTwo2);
  424. printMESA (iTwo <= iMinusThree);
  425. printMESA (iMinusThree <= iTwo);
  426. printMESA (_Two >= _Two);
  427. printMESA (_Two >= _Two2);
  428. printMESA (_Two >= _MinusThree);
  429. printMESA (_MinusThree >= _Two);
  430. printMESA (iTwo >= iTwo);
  431. printMESA (iTwo >= iTwo2);
  432. printMESA (iTwo >= iMinusThree);
  433. printMESA (iMinusThree >= iTwo);
  434. printMESA (_Two < _Two);
  435. printMESA (_Two < _Two2);
  436. printMESA (_Two < _MinusThree);
  437. printMESA (_MinusThree < _Two);
  438. printMESA (iTwo < iTwo);
  439. printMESA (iTwo < iTwo2);
  440. printMESA (iTwo < iMinusThree);
  441. printMESA (iMinusThree < iTwo);
  442. printMESA (_Two > _Two);
  443. printMESA (_Two > _Two2);
  444. printMESA (_Two > _MinusThree);
  445. printMESA (_MinusThree > _Two);
  446. printMESA (iTwo > iTwo);
  447. printMESA (iTwo > iTwo2);
  448. printMESA (iTwo > iMinusThree);
  449. printMESA (iMinusThree > iTwo);
  450. printMESA (_Two == _Two);
  451. printMESA (_Two == _Two2);
  452. printMESA (_Two == _MinusThree);
  453. printMESA (_MinusThree == _MinusThree);
  454. printMESA (iTwo == iTwo);
  455. printMESA (iTwo == iTwo2);
  456. printMESA (iTwo == iMinusThree);
  457. printMESA (iMinusThree == iMinusThree);
  458. printMESA (_Two != _Two);
  459. printMESA (_Two != _Two2);
  460. printMESA (_Two != _MinusThree);
  461. printMESA (_MinusThree != _MinusThree);
  462. printMESA (iTwo != iTwo);
  463. printMESA (iTwo != iTwo2);
  464. printMESA (iTwo != iMinusThree);
  465. printMESA (iMinusThree != iMinusThree);
  466. foo foo1;
  467. foo1.f = 13.31;
  468. foo1.v4 = vec4 (44.11, 44.22, 44.33, 44.44);
  469. foo1.v3 = vec3 (33.11, 33.22, 33.33);
  470. foo1.m4 = mat4 (17.88);
  471. foo1.i = 666;
  472. foo1.b = true;
  473. printMESA (foo1);
  474. // make foo2 the same as foo1
  475. foo foo2;
  476. foo2.f = 13.31;
  477. foo2.v4 = vec4 (44.11, 44.22, 44.33, 44.44);
  478. foo2.v3 = vec3 (33.11, 33.22, 33.33);
  479. foo2.m4 = mat4 (17.88);
  480. foo2.i = 666;
  481. foo2.b = true;
  482. printMESA (foo1 == foo2);
  483. printMESA (foo1 != foo2);
  484. // make them a little bit different
  485. foo2.m4[2].y = 333.333;
  486. printMESA (foo2);
  487. printMESA (foo1 == foo2);
  488. printMESA (foo1 != foo2);
  489. }
  490. $output
  491. true
  492. true
  493. false
  494. true
  495. true
  496. true
  497. false
  498. true
  499. true
  500. true
  501. true
  502. false
  503. true
  504. true
  505. true
  506. false
  507. false
  508. false
  509. false
  510. true
  511. false
  512. false
  513. false
  514. true
  515. false
  516. false
  517. true
  518. false
  519. false
  520. false
  521. true
  522. false
  523. true
  524. true
  525. false
  526. true
  527. true
  528. true
  529. false
  530. true
  531. false
  532. false
  533. true
  534. false
  535. false
  536. false
  537. true
  538. false
  539. 13.31
  540. 44.11
  541. 44.22
  542. 44.33
  543. 44.44
  544. 33.11
  545. 33.22
  546. 33.33
  547. 17.88
  548. 0.0
  549. 0.0
  550. 0.0
  551. 0.0
  552. 17.88
  553. 0.0
  554. 0.0
  555. 0.0
  556. 0.0
  557. 17.88
  558. 0.0
  559. 0.0
  560. 0.0
  561. 0.0
  562. 17.88
  563. 666
  564. true
  565. true
  566. false
  567. 13.31
  568. 44.11
  569. 44.22
  570. 44.33
  571. 44.44
  572. 33.11
  573. 33.22
  574. 33.33
  575. 17.88
  576. 0.0
  577. 0.0
  578. 0.0
  579. 0.0
  580. 17.88
  581. 0.0
  582. 0.0
  583. 0.0
  584. 333.333
  585. 17.88
  586. 0.0
  587. 0.0
  588. 0.0
  589. 0.0
  590. 17.88
  591. 666
  592. true
  593. false
  594. true
  595. $ /*
  596. $ --------------------------------------------------------------------------------------------------
  597. $ Test logical operators.
  598. $ */
  599. $program LOGICAL OPERATOR TEST
  600. $attrib gl_Vertex
  601. 0.0 0.0 0.0 1.0
  602. $attrib _False
  603. 0.0 0.0 0.0 0.0
  604. $attrib _True
  605. 1.0 0.0 0.0 0.0
  606. $attrib _False2
  607. 0.0 0.0 0.0 0.0
  608. $attrib _True2
  609. 1.0 0.0 0.0 0.0
  610. $vertex
  611. $code
  612. #version 110
  613. #extension MESA_shader_debug: require
  614. attribute float _False;
  615. attribute float _True;
  616. attribute float _False2;
  617. attribute float _True2;
  618. void main () {
  619. gl_Position = gl_ModelViewMatrix * gl_Vertex;
  620. gl_FrontColor = vec4 (1.0);
  621. printMESA (_False);
  622. printMESA (_True);
  623. printMESA (_False2);
  624. printMESA (_True2);
  625. bool False = bool (_False);
  626. bool True = bool (_True);
  627. bool False2 = bool (_False2);
  628. bool True2 = bool (_True2);
  629. //
  630. // It is important to test each operator with the following argument types:
  631. // * Both arguments are different variables, even if they have the same values.
  632. // False and False2 are distinct attributes, but are the same in value.
  633. // * Both arguments may be the same variables. This case tests possible
  634. // optimizations, e.g. X && X --> X.
  635. // * Both arguments are constant. This tests constant folding.
  636. //
  637. printMESA (!False);
  638. printMESA (!True);
  639. printMESA (!false);
  640. printMESA (!true);
  641. printMESA (False ^^ False2);
  642. printMESA (False ^^ True2);
  643. printMESA (True ^^ False2);
  644. printMESA (True ^^ True2);
  645. printMESA (False ^^ False);
  646. printMESA (False ^^ True);
  647. printMESA (True ^^ False);
  648. printMESA (True ^^ True);
  649. printMESA (false ^^ false);
  650. printMESA (false ^^ true);
  651. printMESA (true ^^ false);
  652. printMESA (true ^^ true);
  653. printMESA (False && False2);
  654. printMESA (False && True2);
  655. printMESA (True && False2);
  656. printMESA (True && True2);
  657. printMESA (False && False);
  658. printMESA (False && True);
  659. printMESA (True && False);
  660. printMESA (True && True);
  661. printMESA (false && false);
  662. printMESA (false && true);
  663. printMESA (true && false);
  664. printMESA (true && true);
  665. printMESA (False || False2);
  666. printMESA (False || True2);
  667. printMESA (True || False2);
  668. printMESA (True || True2);
  669. printMESA (False || False);
  670. printMESA (False || True);
  671. printMESA (True || False);
  672. printMESA (True || True);
  673. printMESA (false || false);
  674. printMESA (false || true);
  675. printMESA (true || false);
  676. printMESA (true || true);
  677. //
  678. // Test short-circuit evaluation of && and ||. The right expression evaluation depends
  679. // on the value of the left expression. If the right expression has side effects, we
  680. // can easily test if it happened.
  681. //
  682. bool x;
  683. x = false;
  684. printMESA (x);
  685. printMESA (False && (x = true));
  686. printMESA (x);
  687. x = false;
  688. printMESA (x);
  689. printMESA (false && (x = true));
  690. printMESA (x);
  691. x = true;
  692. printMESA (x);
  693. printMESA (True || (x = false));
  694. printMESA (x);
  695. x = true;
  696. printMESA (x);
  697. printMESA (true || (x = false));
  698. printMESA (x);
  699. }
  700. $output
  701. 0.0
  702. 1.0
  703. 0.0
  704. 1.0
  705. true
  706. false
  707. true
  708. false
  709. false
  710. true
  711. true
  712. false
  713. false
  714. true
  715. true
  716. false
  717. false
  718. true
  719. true
  720. false
  721. false
  722. false
  723. false
  724. true
  725. false
  726. false
  727. false
  728. true
  729. false
  730. false
  731. false
  732. true
  733. false
  734. true
  735. true
  736. true
  737. false
  738. true
  739. true
  740. true
  741. false
  742. true
  743. true
  744. true
  745. false
  746. false
  747. false
  748. false
  749. false
  750. false
  751. true
  752. true
  753. true
  754. true
  755. true
  756. true
  757. $ /*
  758. $ --------------------------------------------------------------------------------------------------
  759. $ Test subscript operator/array access.
  760. $ */
  761. $program ARRAY ACCESS TEST
  762. $attrib gl_Vertex
  763. 0.0 0.0 0.0 1.0
  764. $attrib _Zero
  765. 0.0 0.0 0.0 0.0
  766. $attrib _One
  767. 1.1 0.0 0.0 0.0
  768. $attrib _Two
  769. 2.9 0.0 0.0 0.0
  770. $attrib _Vec
  771. 11.11 22.22 33.33 44.44
  772. $vertex
  773. $code
  774. #version 110
  775. #extension MESA_shader_debug: require
  776. attribute float _Zero;
  777. attribute float _One;
  778. attribute float _Two;
  779. attribute vec4 _Vec;
  780. void main () {
  781. gl_Position = gl_ModelViewMatrix * gl_Vertex;
  782. gl_FrontColor = vec4 (1.0);
  783. printMESA (_Zero);
  784. printMESA (_One);
  785. printMESA (_Two);
  786. printMESA (_Vec);
  787. printMESA (_Vec[0]);
  788. printMESA (_Vec[1]);
  789. printMESA (_Vec[2]);
  790. printMESA (_Vec[3]);
  791. printMESA (_Vec[int (_Zero)]);
  792. printMESA (_Vec[int (_One)]);
  793. printMESA (_Vec[int (_Two)]);
  794. }
  795. $output
  796. 0.0
  797. 1.1
  798. 2.9
  799. 11.11
  800. 22.22
  801. 33.33
  802. 44.44
  803. 11.11
  804. 22.22
  805. 33.33
  806. 44.44
  807. 11.11
  808. 22.22
  809. 33.33
  810. $ /*
  811. $ --------------------------------------------------------------------------------------------------
  812. $ Test pre/post-increment/decrement operators.
  813. $ Note: assumes relational operators being correct.
  814. $ */
  815. $program PRE/POST-INC/DEC OPERATOR TEST
  816. $attrib gl_Vertex
  817. 0.0 0.0 0.0 1.0
  818. $attrib _Zero
  819. 0.0 0.0 0.0 0.0
  820. $attrib _One
  821. 1.1 0.0 0.0 0.0
  822. $attrib _Two4
  823. 2.1 2.2 2.3 2.4
  824. $vertex
  825. $code
  826. #version 110
  827. #extension MESA_shader_debug: require
  828. attribute float _Zero;
  829. attribute float _One;
  830. attribute vec4 _Two4;
  831. float fZero, fOne;
  832. vec4 fTwo4;
  833. int iZero, iOne;
  834. ivec4 iTwo4;
  835. void reset () {
  836. fZero = _Zero;
  837. fOne = _One;
  838. fTwo4 = _Two4;
  839. iZero = int (_Zero);
  840. iOne = int (_One);
  841. iTwo4 = ivec4 (_Two4);
  842. }
  843. void main () {
  844. gl_Position = gl_ModelViewMatrix * gl_Vertex;
  845. gl_FrontColor = vec4 (1.0);
  846. printMESA (_Zero);
  847. printMESA (_One);
  848. printMESA (_Two4);
  849. // pre-increment
  850. reset ();
  851. printMESA (++fZero);
  852. printMESA (++fOne);
  853. printMESA (++iZero);
  854. printMESA (++iOne);
  855. printMESA (fZero);
  856. printMESA (fOne);
  857. printMESA (iZero);
  858. printMESA (iOne);
  859. printMESA (++fTwo4 == _Two4 + 1.0);
  860. printMESA (++iTwo4 == ivec4 (_Two4) + 1);
  861. // pre-decrement
  862. reset ();
  863. printMESA (--fZero);
  864. printMESA (--fOne);
  865. printMESA (--iZero);
  866. printMESA (--iOne);
  867. printMESA (fZero);
  868. printMESA (fOne);
  869. printMESA (iZero);
  870. printMESA (iOne);
  871. printMESA (--fTwo4 == _Two4 - 1.0);
  872. printMESA (--iTwo4 == ivec4 (_Two4) - 1);
  873. // post-increment
  874. reset ();
  875. printMESA (fZero++);
  876. printMESA (fOne++);
  877. printMESA (iZero++);
  878. printMESA (iOne++);
  879. printMESA (fZero);
  880. printMESA (fOne);
  881. printMESA (iZero);
  882. printMESA (iOne);
  883. printMESA (fTwo4++ == _Two4);
  884. printMESA (iTwo4++ == ivec4 (_Two4));
  885. // post-decrement
  886. reset ();
  887. printMESA (fZero--);
  888. printMESA (fOne--);
  889. printMESA (iZero--);
  890. printMESA (iOne--);
  891. printMESA (fZero);
  892. printMESA (fOne);
  893. printMESA (iZero);
  894. printMESA (iOne);
  895. printMESA (fTwo4-- == _Two4);
  896. printMESA (iTwo4-- == ivec4 (_Two4));
  897. }
  898. $output
  899. 0.0
  900. 1.1
  901. 2.1
  902. 2.2
  903. 2.3
  904. 2.4
  905. 1.0
  906. 2.1
  907. 1
  908. 2
  909. 1.0
  910. 2.1
  911. 1
  912. 2
  913. true
  914. true
  915. -1.0
  916. 0.1
  917. -1
  918. 0
  919. -1.0
  920. 0.1
  921. -1
  922. 0
  923. true
  924. true
  925. 0.0
  926. 1.1
  927. 0
  928. 1
  929. 1.0
  930. 2.1
  931. 1
  932. 2
  933. true
  934. true
  935. 0.0
  936. 1.1
  937. 0
  938. 1
  939. -1.0
  940. 0.1
  941. -1
  942. 0
  943. true
  944. true
  945. $ /*
  946. $ --------------------------------------------------------------------------------------------------
  947. $ Test arithmetical operators.
  948. $ */
  949. $program ARITHMETICAL OPERATOR TEST
  950. $attrib gl_Vertex
  951. 0.0 0.0 0.0 1.0
  952. $attrib _Zero
  953. 0.0 0.0 0.0 0.0
  954. $attrib _One
  955. 1.1 0.0 0.0 0.0
  956. $attrib _Two4
  957. 2.1 2.2 2.3 2.4
  958. $vertex
  959. $code
  960. #version 110
  961. #extension MESA_shader_debug: require
  962. attribute float _Zero;
  963. attribute float _One;
  964. attribute vec4 _Two4;
  965. void main () {
  966. gl_Position = gl_ModelViewMatrix * gl_Vertex;
  967. gl_FrontColor = vec4 (1.0);
  968. printMESA (_Zero);
  969. printMESA (_One);
  970. printMESA (_Two4);
  971. int iZero = int (_Zero);
  972. int iOne = int (_One);
  973. ivec4 iTwo4 = ivec4 (_Two4);
  974. printMESA (-_Zero);
  975. printMESA (-_One);
  976. printMESA (-_Two4);
  977. printMESA (-_Two4.z);
  978. printMESA (_Zero + 0.0);
  979. printMESA (_One + 0.0);
  980. printMESA (_Two4 + 0.0);
  981. printMESA (_Two4.y + 0.0);
  982. printMESA (_Zero + _Zero);
  983. printMESA (_Zero + _One);
  984. printMESA (_Zero + _Two4);
  985. printMESA (_One + _Zero);
  986. printMESA (_One + _Two4);
  987. printMESA (_Two4 + _Two4);
  988. printMESA (_Zero - 0.0);
  989. printMESA (_One - 0.0);
  990. printMESA (_Two4 - 0.0);
  991. printMESA (_Two4.y - 0.0);
  992. printMESA (_Zero - _Zero);
  993. printMESA (_Zero - _One);
  994. printMESA (_Zero - _Two4);
  995. printMESA (_One - _Zero);
  996. printMESA (_One - _Two4);
  997. printMESA (_Two4 - _Two4);
  998. printMESA (_Zero * 1.0);
  999. printMESA (_One * 1.0);
  1000. printMESA (_Two4 * 1.0);
  1001. printMESA (_Two4.x * 1.0);
  1002. printMESA (_Zero * _Zero);
  1003. printMESA (_Zero * _One);
  1004. printMESA (_Zero * _Two4);
  1005. printMESA (_One * _Zero);
  1006. printMESA (_One * _One);
  1007. printMESA (_One * _Two4);
  1008. printMESA (_Two4 * _Two4);
  1009. printMESA (_Zero / 1.0);
  1010. printMESA (_One / 1.0);
  1011. printMESA (_Two4 / 1.0);
  1012. printMESA (_Two4.x / 1.0);
  1013. printMESA (_Zero / _One);
  1014. printMESA (_Zero / _Two4);
  1015. printMESA (_One / _One);
  1016. printMESA (_One / _Two4);
  1017. printMESA (_Two4 / _Two4);
  1018. }
  1019. $output
  1020. 0.0
  1021. 1.1
  1022. 2.1
  1023. 2.2
  1024. 2.3
  1025. 2.4
  1026. 0.0
  1027. -1.1
  1028. -2.1
  1029. -2.2
  1030. -2.3
  1031. -2.4
  1032. -2.3
  1033. 0.0
  1034. 1.1
  1035. 2.1
  1036. 2.2
  1037. 2.3
  1038. 2.4
  1039. 2.2
  1040. 0.0
  1041. 1.1
  1042. 2.1
  1043. 2.2
  1044. 2.3
  1045. 2.4
  1046. 1.1
  1047. 3.2
  1048. 3.3
  1049. 3.4
  1050. 3.5
  1051. 4.2
  1052. 4.4
  1053. 4.6
  1054. 4.8
  1055. 0.0
  1056. 1.1
  1057. 2.1
  1058. 2.2
  1059. 2.3
  1060. 2.4
  1061. 2.2
  1062. 0.0
  1063. -1.1
  1064. -2.1
  1065. -2.2
  1066. -2.3
  1067. -2.4
  1068. 1.1
  1069. -1.0
  1070. -1.1
  1071. -1.2
  1072. -1.3
  1073. 0.0
  1074. 0.0
  1075. 0.0
  1076. 0.0
  1077. 0.0
  1078. 1.1
  1079. 2.1
  1080. 2.2
  1081. 2.3
  1082. 2.4
  1083. 2.1
  1084. 0.0
  1085. 0.0
  1086. 0.0
  1087. 0.0
  1088. 0.0
  1089. 0.0
  1090. 0.0
  1091. 1.21
  1092. 2.31
  1093. 2.42
  1094. 2.53
  1095. 2.64
  1096. 4.41
  1097. 4.84
  1098. 5.29
  1099. 5.76
  1100. 0.0
  1101. 1.1
  1102. 2.1
  1103. 2.2
  1104. 2.3
  1105. 2.4
  1106. 2.1
  1107. 0.0
  1108. 0.0
  1109. 0.0
  1110. 0.0
  1111. 0.0
  1112. 1.0
  1113. 0.52381
  1114. 0.5
  1115. 0.47826
  1116. 0.45833
  1117. 1.0
  1118. 1.0
  1119. 1.0
  1120. 1.0
  1121. $ /*
  1122. $ --------------------------------------------------------------------------------------------------
  1123. $ Test matrix operations.
  1124. $ Note: assumes relational operators being correct.
  1125. $ */
  1126. $program MATRIX TEST
  1127. $attrib gl_Vertex
  1128. 0.0 0.0 0.0 1.0
  1129. $attrib _Zero
  1130. 0.0 0.0 0.0 0.0
  1131. $attrib _One
  1132. 1.0 1.0 1.0 1.0
  1133. $attrib _Two
  1134. 2.0 2.0 2.0 2.0
  1135. $vertex
  1136. $code
  1137. #version 110
  1138. #extension MESA_shader_debug: require
  1139. attribute vec4 _Zero;
  1140. attribute vec4 _One;
  1141. attribute vec4 _Two;
  1142. void main () {
  1143. gl_Position = gl_ModelViewMatrix * gl_Vertex;
  1144. gl_FrontColor = vec4 (1.0);
  1145. printMESA (_Zero);
  1146. printMESA (_One);
  1147. printMESA (_Two);
  1148. mat4 Identity = mat4 (_One.x);
  1149. printMESA (Identity == mat4 (1.0, 0.0, 0.0, 0.0,
  1150. 0.0, 1.0, 0.0, 0.0,
  1151. 0.0, 0.0, 1.0, 0.0,
  1152. 0.0, 0.0, 0.0, 1.0));
  1153. printMESA (Identity * _Two == _Two);
  1154. mat4 Matrix = mat4 (1.1, 1.2, 1.3, 1.4,
  1155. 2.1, 2.2, 2.3, 2.4,
  1156. 3.1, 3.2, 3.3, 3.4,
  1157. 4.1, 4.2, 4.3, 4.4);
  1158. printMESA (Matrix[2].y);
  1159. printMESA (Matrix[1]);
  1160. }
  1161. $output
  1162. 0.0
  1163. 0.0
  1164. 0.0
  1165. 0.0
  1166. 1.0
  1167. 1.0
  1168. 1.0
  1169. 1.0
  1170. 2.0
  1171. 2.0
  1172. 2.0
  1173. 2.0
  1174. true
  1175. true
  1176. 3.2
  1177. 2.1
  1178. 2.2
  1179. 2.3
  1180. 2.4
  1181. $ /*
  1182. $ --------------------------------------------------------------------------------------------------
  1183. $ Test vec4 extension operations.
  1184. $ */
  1185. $program VEC4 EXTENSION OPERATIONS
  1186. $attrib gl_Vertex
  1187. 0.0 0.0 0.0 1.0
  1188. $attrib _One
  1189. 1.1 0.0 0.0 0.0
  1190. $attrib _Two4
  1191. 2.1 2.2 2.3 2.4
  1192. $attrib _Three4
  1193. 3.1 3.2 3.3 3.4
  1194. $vertex
  1195. $code
  1196. #version 110
  1197. #extension MESA_shader_debug: require
  1198. attribute float _One;
  1199. attribute vec4 _Two4;
  1200. attribute vec4 _Three4;
  1201. void main () {
  1202. gl_Position = gl_ModelViewMatrix * gl_Vertex;
  1203. gl_FrontColor = vec4 (1.0);
  1204. printMESA (_One);
  1205. printMESA (_Two4);
  1206. printMESA (_Three4);
  1207. printMESA (vec4 (_One));
  1208. printMESA (_Two4 + _Three4);
  1209. printMESA (_Two4 - _Three4);
  1210. printMESA (_Two4 * _Three4);
  1211. printMESA (_Two4 / _Three4);
  1212. printMESA (_Two4 + _One);
  1213. printMESA (_Two4 - _One);
  1214. printMESA (_Two4 * _One);
  1215. printMESA (_Two4 / _One);
  1216. printMESA (_One + _Two4);
  1217. printMESA (_One - _Two4);
  1218. printMESA (_One * _Two4);
  1219. printMESA (_One / _Two4);
  1220. printMESA (-_Three4);
  1221. printMESA (dot (_Two4.xyz, _Three4.xyz));
  1222. printMESA (dot (_Two4, _Three4));
  1223. printMESA (length (_Two4.xyz));
  1224. printMESA (length (_Three4));
  1225. printMESA (normalize (_Two4.xyz));
  1226. printMESA (normalize (_Three4));
  1227. vec4 tmp = _Two4;
  1228. printMESA (tmp);
  1229. printMESA (_Two4 == _Three4);
  1230. printMESA (_Two4 != _Three4);
  1231. printMESA (_Two4 == _Two4);
  1232. printMESA (_Three4 != _Three4);
  1233. printMESA (_Two4 != vec4 (_Two4.xyz, 999.0));
  1234. printMESA (_Two4 != vec4 (999.0, _Two4.yzw));
  1235. }
  1236. $output
  1237. 1.1
  1238. 2.1
  1239. 2.2
  1240. 2.3
  1241. 2.4
  1242. 3.1
  1243. 3.2
  1244. 3.3
  1245. 3.4
  1246. 1.1
  1247. 1.1
  1248. 1.1
  1249. 1.1
  1250. 5.2
  1251. 5.4
  1252. 5.6
  1253. 5.8
  1254. -1.0
  1255. -1.0
  1256. -1.0
  1257. -1.0
  1258. 6.51
  1259. 7.04
  1260. 7.59
  1261. 8.16
  1262. 0.677419
  1263. 0.6875
  1264. 0.69697
  1265. 0.705882
  1266. 3.2
  1267. 3.3
  1268. 3.4
  1269. 3.5
  1270. 1.0
  1271. 1.1
  1272. 1.2
  1273. 1.3
  1274. 2.31
  1275. 2.42
  1276. 2.53
  1277. 2.64
  1278. 1.909091
  1279. 2.0
  1280. 2.090909
  1281. 2.181818
  1282. 3.2
  1283. 3.3
  1284. 3.4
  1285. 3.5
  1286. -1.0
  1287. -1.1
  1288. -1.2
  1289. -1.3
  1290. 2.31
  1291. 2.42
  1292. 2.53
  1293. 2.64
  1294. 0.52381
  1295. 0.5
  1296. 0.478261
  1297. 0.458333
  1298. -3.1
  1299. -3.2
  1300. -3.3
  1301. -3.4
  1302. 21.14
  1303. 29.3
  1304. 3.813135
  1305. 6.503845
  1306. 0.550728
  1307. 0.576953
  1308. 0.603178
  1309. 0.476641
  1310. 0.492017
  1311. 0.507392
  1312. 0.522768
  1313. 2.1
  1314. 2.2
  1315. 2.3
  1316. 2.4
  1317. false
  1318. true
  1319. true
  1320. false
  1321. true
  1322. true