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.

2175 lines
59 KiB

  1. ;---------------------------Module-Header------------------------------;
  2. ; Module Name: xform.asm
  3. ;
  4. ; xform routines.
  5. ;
  6. ; Created: 09/28/1995
  7. ; Author: Hock San Lee [hockl]
  8. ;
  9. ; Copyright (c) 1995 Microsoft Corporation
  10. ;----------------------------------------------------------------------;
  11. .386
  12. .model small,pascal
  13. assume cs:FLAT,ds:FLAT,es:FLAT,ss:FLAT
  14. assume fs:nothing,gs:nothing
  15. .xlist
  16. include gli386.inc
  17. .list
  18. PROFILE = 0
  19. include profile.inc
  20. .data
  21. extrn _invSqrtTable: DWORD
  22. ;; This debug equate will enable printf-type tracking of the transform calls--
  23. ;; quite handy for conformance-type failures. '2' will always print, '1' will
  24. ;; only print the first time...
  25. ;;DEBUG EQU 2
  26. ifdef DEBUG
  27. str1 db 'xform1 ',0
  28. str2 db 'xform2 ',0
  29. str3 db 'xform3 ',0
  30. str4 db 'xform4 ',0
  31. str5 db 'xform5 ',0
  32. str6 db 'xform6 ',0
  33. str7 db 'xform7 ',0
  34. str8 db 'xform8 ',0
  35. str9 db 'xform9 ',0
  36. str10 db 'xform10 ',0
  37. str11 db 'xform11 ',0
  38. str12 db 'xform12 ',0
  39. str13 db 'xform13 ',0
  40. str14 db 'xform14 ',0
  41. str15 db 'xform15 ',0
  42. endif
  43. .code
  44. ifdef DEBUG
  45. if DEBUG eq 1
  46. DBGPRINTID MACRO idNum
  47. push ecx
  48. push edx
  49. mov edx, offset idNum
  50. cmp byte ptr [edx][0], 0
  51. je @@1
  52. push offset idNum
  53. call DWORD PTR __imp__OutputDebugStringA@4
  54. mov edx, offset idNum
  55. mov byte ptr [edx][0], 0
  56. @@1:
  57. pop edx
  58. pop ecx
  59. ENDM
  60. elseif DEBUG eq 2
  61. DBGPRINTID MACRO idNum
  62. push ecx
  63. push edx
  64. push offset idNum
  65. call DWORD PTR __imp__OutputDebugStringA@4
  66. pop edx
  67. pop ecx
  68. ENDM
  69. endif
  70. else
  71. DBGPRINTID MACRO idNum
  72. ENDM
  73. endif
  74. align 4
  75. EXTRN __imp__OutputDebugStringA@4:NEAR
  76. ;
  77. ; Note: These xform routines must allow for the case where the result
  78. ; vector is equal to the source vector.
  79. ;
  80. ; The basic assumptions below are that multiplies and adds have a 3-cycle
  81. ; latency that can be hidden using pipelining, fxch is free when paired with
  82. ; fadd and fmul, and that the latency for fld is always 1.
  83. ;
  84. ; The goal is to have each line below consume either 1 or 0 cycles (fxch).
  85. ; There's not much we can do at the end of the routine, since we have no
  86. ; choice but to wait for the last couple of intructions to get through the
  87. ; pipeline.
  88. ;
  89. ;
  90. ; The comments show the age and position of the elements in the pipeline
  91. ; (when relevant). Items with higher numbers are newer (in the pipeline)
  92. ; than items with lower numbers. The entries are ordered from stack
  93. ; positions 0-7, left to right.
  94. ;
  95. ; Note that computetions for the terms are intermixed to allow eliminate
  96. ; latency where possible. Unfortunately, this makes the code hard to
  97. ; follow. That's probably why the compiler won't generate code like
  98. ; this...
  99. ;
  100. ; --- Otto ---
  101. ;
  102. _X_ EQU 0
  103. _Y_ EQU 4
  104. _Z_ EQU 8
  105. _W_ EQU 12
  106. ;------------------------------Public-Routine------------------------------
  107. ;
  108. ; Avoid some transformation computations by knowing that the incoming
  109. ; vertex has w=1.
  110. ;
  111. ; res->x = x*m->matrix[0][0] + y*m->matrix[1][0] + z*m->matrix[2][0]
  112. ; + m->matrix[3][0];
  113. ; res->y = x*m->matrix[0][1] + y*m->matrix[1][1] + z*m->matrix[2][1]
  114. ; + m->matrix[3][1];
  115. ; res->z = x*m->matrix[0][2] + y*m->matrix[1][2] + z*m->matrix[2][2]
  116. ; + m->matrix[3][2];
  117. ; res->w = x*m->matrix[0][3] + y*m->matrix[1][3] + z*m->matrix[2][3]
  118. ; + m->matrix[3][3];
  119. ;
  120. ; History:
  121. ; Thu 28-Sep-1995 -by- Otto Berkes [ottob]
  122. ; Wrote it.
  123. ;--------------------------------------------------------------------------
  124. __GL_ASM_XFORM3 MACRO input, result
  125. ;EAX = m->matrix
  126. ;EDX = v[]
  127. ;---------------------------------------------------------------------------
  128. ; Start computation for x term:
  129. ;---------------------------------------------------------------------------
  130. fld DWORD PTR [input][_X_] ; x1
  131. fmul DWORD PTR [eax][__MATRIX_M00]
  132. fld DWORD PTR [input][_Y_] ; x2 x1
  133. fmul DWORD PTR [eax][__MATRIX_M10]
  134. fld DWORD PTR [input][_Z_] ; x3 x2 x1
  135. fmul DWORD PTR [eax][__MATRIX_M20]
  136. fxch ST(2) ; x1 x2 x3
  137. fadd DWORD PTR [eax][__MATRIX_M30] ; x3 x1 x2
  138. ;---------------------------------------------------------------------------
  139. ; Start computation for y term:
  140. ;---------------------------------------------------------------------------
  141. fld DWORD PTR [input][_X_]
  142. fmul DWORD PTR [eax][__MATRIX_M01] ; y1 x x x
  143. ;
  144. ; OVERLAP -- compute second add for previous term
  145. ;
  146. fxch ST(1) ; x y1 x x
  147. faddp ST(2),ST(0) ; y1 x x
  148. ;
  149. fld DWORD PTR [input][_Y_]
  150. fmul DWORD PTR [eax][__MATRIX_M11] ; y2 y1 x x
  151. ;
  152. ; OVERLAP -- compute previous final term
  153. ;
  154. fxch ST(2) ; x y1 y2 x
  155. faddp ST(3),ST(0) ; y1 y2 x
  156. ;
  157. fld DWORD PTR [input][_Z_]
  158. fmul DWORD PTR [eax][__MATRIX_M21] ; y3 y1 y2 x
  159. fxch ST(1) ; y1 y3 y2 x
  160. fadd DWORD PTR [eax][__MATRIX_M31] ; y3 y2 y1 x
  161. ;
  162. ;---------------------------------------------------------------------------
  163. ; Start computation for z term:
  164. ;---------------------------------------------------------------------------
  165. fld DWORD PTR [input][_X_]
  166. fmul DWORD PTR [eax][__MATRIX_M02] ; z1 y y y x
  167. ;
  168. ; OVERLAP -- compute second add for previous result
  169. ;
  170. fxch ST(1) ; y z1 y y x
  171. faddp ST(2),ST(0) ; z1 y y x
  172. ;
  173. fld DWORD PTR [input][_Y_]
  174. fmul DWORD PTR [eax][__MATRIX_M12] ; z2 z1 y y x
  175. ;
  176. ; OVERLAP -- compute previous final result
  177. ;
  178. fxch ST(2) ; y z1 z2 y x
  179. faddp ST(3),ST(0) ; z1 z2 y x
  180. ;
  181. fld DWORD PTR [input][_Z_]
  182. fmul DWORD PTR [eax][__MATRIX_M22] ; z3 z1 z2 y x
  183. fxch ST(1) ; z1 z3 z2 y x
  184. fadd DWORD PTR [eax][__MATRIX_M32] ; z3 z1 z2 y x
  185. ;
  186. ;---------------------------------------------------------------------------
  187. ; Start computation for w term:
  188. ;---------------------------------------------------------------------------
  189. fld DWORD PTR [input][_X_]
  190. fmul DWORD PTR [eax][__MATRIX_M03] ; w1 z z z y x
  191. ;
  192. ; OVERLAP -- compute second add for previous result
  193. ;
  194. fxch ST(1) ; z w1 z z y x
  195. faddp ST(2),ST(0) ; w1 z z y x
  196. ;
  197. fld DWORD PTR [input][_Y_]
  198. fmul DWORD PTR [eax][__MATRIX_M13] ; w2 w1 z z y x
  199. ;
  200. ; OVERLAP -- compute previous final result
  201. ;
  202. fxch ST(2) ; z w1 w2 z y x
  203. faddp ST(3),ST(0) ; w1 w2 z y x
  204. ;
  205. fld DWORD PTR [input][_Z_]
  206. fmul DWORD PTR [eax][__MATRIX_M23] ; w3 w1 w2 z y x
  207. fxch ST(1) ; w1 w3 w2 z y x
  208. fadd DWORD PTR [eax][__MATRIX_M33] ; w3 w2 w1 z y x
  209. fxch ST(1) ; w2 w3 w1 z y x
  210. faddp ST(2),ST(0) ; w1 w2 z y x
  211. ;
  212. ; OVERLAP -- store final x
  213. ;
  214. fxch ST(4) ; x w2 z y w1
  215. fstp DWORD PTR [result][_X_] ; w2 z y w1
  216. ;
  217. faddp ST(3),ST(0) ; z y w
  218. ;
  219. ; store final z, y, w
  220. ;
  221. fstp DWORD PTR [result][_Z_] ; y w
  222. fstp DWORD PTR [result][_Y_] ; w
  223. fstp DWORD PTR [result][_W_] ; (empty)
  224. ENDM
  225. ;------------------------------Public-Routine------------------------------
  226. ;
  227. ; Full 4x4 transformation.
  228. ;
  229. ; if (w == ((__GLfloat) 1.0)) {
  230. ; __glXForm3(res, v, m);
  231. ; } else {
  232. ; res->x = x*m->matrix[0][0] + y*m->matrix[1][0] + z*m->matrix[2][0]
  233. ; + w*m->matrix[3][0];
  234. ; res->y = x*m->matrix[0][1] + y*m->matrix[1][1] + z*m->matrix[2][1]
  235. ; + w*m->matrix[3][1];
  236. ; res->z = x*m->matrix[0][2] + y*m->matrix[1][2] + z*m->matrix[2][2]
  237. ; + w*m->matrix[3][2];
  238. ; res->w = x*m->matrix[0][3] + y*m->matrix[1][3] + z*m->matrix[2][3]
  239. ; + w*m->matrix[3][3];
  240. ; }
  241. ;
  242. ; History:
  243. ; Thu 28-Sep-1995 -by- Otto Berkes [ottob]
  244. ; Wrote it.
  245. ;--------------------------------------------------------------------------
  246. __GL_ASM_XFORM4 MACRO input, result
  247. ;EAX = m->matrix
  248. ;EDX = v[]
  249. ;---------------------------------------------------------------------------
  250. ; Start computation for x term:
  251. ;---------------------------------------------------------------------------
  252. fld DWORD PTR [input][_X_] ; x1
  253. fmul DWORD PTR [eax][__MATRIX_M00]
  254. fld DWORD PTR [input][_Y_] ; x2 x1
  255. fmul DWORD PTR [eax][__MATRIX_M10]
  256. fld DWORD PTR [input][_Z_] ; x3 x2 x1
  257. fmul DWORD PTR [eax][__MATRIX_M20]
  258. fld DWORD PTR [input][_W_] ; x4 x3 x2 x1
  259. fmul DWORD PTR [eax][__MATRIX_M30]
  260. ;---------------------------------------------------------------------------
  261. ; Start computation for y term:
  262. ;---------------------------------------------------------------------------
  263. fld DWORD PTR [input][_X_]
  264. fmul DWORD PTR [eax][__MATRIX_M01] ; y1 x x x x
  265. ;
  266. ; OVERLAP -- compute first add for previous term
  267. ;
  268. fxch ST(1) ; x y1 x x x
  269. faddp ST(2),ST(0) ; y1 x x x
  270. ;
  271. fld DWORD PTR [input][_Y_]
  272. fmul DWORD PTR [eax][__MATRIX_M11] ; y2 y1 x x x
  273. ;
  274. ; OVERLAP -- compute second add for previous term
  275. ;
  276. fxch ST(2) ; x y1 y2 x x
  277. faddp ST(3),ST(0) ; y1 y2 x x
  278. ;
  279. fld DWORD PTR [input][_Z_]
  280. fmul DWORD PTR [eax][__MATRIX_M21] ; y3 y1 y2 x x
  281. ;
  282. ; OVERLAP -- compute previous final term
  283. ;
  284. fxch ST(3) ; x y1 y2 y3 x
  285. faddp ST(4),ST(0) ; y1 y2 y3 x
  286. ;
  287. fld DWORD PTR [input][_W_] ; y4 y1 y2 y3 x
  288. fmul DWORD PTR [eax][__MATRIX_M31]
  289. ;
  290. ;---------------------------------------------------------------------------
  291. ; Start computation for z term:
  292. ;---------------------------------------------------------------------------
  293. fld DWORD PTR [input][_X_]
  294. fmul DWORD PTR [eax][__MATRIX_M02] ; z1 y y y y x
  295. ;
  296. ; OVERLAP -- compute first add for previous term
  297. ;
  298. fxch ST(1) ; y z1 y y y x
  299. faddp ST(2),ST(0) ; z1 y y y x
  300. ;
  301. fld DWORD PTR [input][_Y_]
  302. fmul DWORD PTR [eax][__MATRIX_M12] ; z2 z1 y y y x
  303. ;
  304. ; OVERLAP -- compute second add for previous term
  305. ;
  306. fxch ST(2) ; y z1 z2 y y x
  307. faddp ST(3),ST(0) ; z1 z2 y y x
  308. ;
  309. fld DWORD PTR [input][_Z_]
  310. fmul DWORD PTR [eax][__MATRIX_M22] ; z3 z1 z2 y y x
  311. ;
  312. ; OVERLAP -- compute previous final term
  313. ;
  314. fxch ST(3) ; y z1 z2 z3 y x
  315. faddp ST(4),ST(0) ; z1 z2 z3 y x
  316. ;
  317. fld DWORD PTR [input][_W_] ; z4 z1 z2 z3 y x
  318. fmul DWORD PTR [eax][__MATRIX_M32]
  319. ;---------------------------------------------------------------------------
  320. ; Start computation for w term:
  321. ;---------------------------------------------------------------------------
  322. fld DWORD PTR [input][_X_]
  323. fmul DWORD PTR [eax][__MATRIX_M03] ; w1 z z z z y x
  324. ;
  325. ; OVERLAP -- compute first add for previous term
  326. ;
  327. fxch ST(1) ; z w1 z z z y x
  328. faddp ST(2),ST(0) ; w1 z z z y x
  329. ;
  330. fld DWORD PTR [input][_Y_]
  331. fmul DWORD PTR [eax][__MATRIX_M13] ; w2 w1 z z z y x
  332. ;
  333. ; OVERLAP -- compute second add for previous term
  334. ;
  335. fxch ST(2) ; z w1 w2 z z y x
  336. faddp ST(3),ST(0) ; w1 w2 z z y x
  337. faddp ST(1), ST(0) ; w1 z z y x
  338. ;
  339. fld DWORD PTR [input][_Z_]
  340. fmul DWORD PTR [eax][__MATRIX_M23] ; w2 w1 z z y x
  341. ;
  342. ; OVERLAP -- compute previous final term
  343. ;
  344. fxch ST(2) ; z w1 w2 z y x
  345. faddp ST(3),ST(0) ; w1 w2 z y x
  346. faddp ST(1), ST(0) ; w z y x
  347. ;
  348. fld DWORD PTR [input][_W_] ; w2 w1 z y x
  349. fmul DWORD PTR [eax][__MATRIX_M33]
  350. ;
  351. ; OVERLAP -- store final x
  352. ;
  353. fxch ST(4) ; x w1 z y w2
  354. fstp DWORD PTR [result][_X_] ; w1 z y w2
  355. ;
  356. faddp ST(3),ST(0) ; z y w
  357. ;
  358. ; store final z, y, w
  359. ;
  360. fstp DWORD PTR [result][_Z_] ; y w
  361. fstp DWORD PTR [result][_Y_] ; w
  362. fstp DWORD PTR [result][_W_] ; (empty)
  363. ENDM
  364. ;------------------------------Public-Routine------------------------------
  365. ;
  366. ; Avoid some transformation computations by knowing that the incoming
  367. ; vertex has z=0 and w=1
  368. ;
  369. ; res->x = x*m->matrix[0][0] + y*m->matrix[1][0] + m->matrix[3][0];
  370. ; res->y = x*m->matrix[0][1] + y*m->matrix[1][1] + m->matrix[3][1];
  371. ; res->z = x*m->matrix[0][2] + y*m->matrix[1][2] + m->matrix[3][2];
  372. ; res->w = x*m->matrix[0][3] + y*m->matrix[1][3] + m->matrix[3][3];
  373. ;
  374. ; History:
  375. ; Thu 28-Sep-1995 -by- Otto Berkes [ottob]
  376. ; Wrote it.
  377. ;--------------------------------------------------------------------------
  378. __GL_ASM_XFORM2 MACRO input, result
  379. ;EAX = m->matrix
  380. ;EDX = v[]
  381. ;---------------------------------------------------------------------------
  382. ; Start computation for x term:
  383. ;---------------------------------------------------------------------------
  384. fld DWORD PTR [input][_X_] ; x1
  385. fmul DWORD PTR [eax][__MATRIX_M00]
  386. fld DWORD PTR [input][_Y_] ; x2 x1
  387. fmul DWORD PTR [eax][__MATRIX_M10]
  388. ;---------------------------------------------------------------------------
  389. ; Start computation for y term:
  390. ;---------------------------------------------------------------------------
  391. fld DWORD PTR [input][_X_]
  392. fmul DWORD PTR [eax][__MATRIX_M01] ; y1 x x
  393. ;
  394. ; OVERLAP -- compute second add for previous term
  395. ;
  396. fxch ST(1) ; x y1 x
  397. fadd DWORD PTR [eax][__MATRIX_M30] ; x y1 x
  398. fxch ST(1) ; y1 x x
  399. fld DWORD PTR [input][_Y_]
  400. fmul DWORD PTR [eax][__MATRIX_M11] ; y2 y1 x x
  401. ;
  402. ; OVERLAP -- compute previous final term
  403. ;
  404. fxch ST(2) ; x y1 y2 x
  405. faddp ST(3),ST(0) ; y1 y2 x
  406. ;---------------------------------------------------------------------------
  407. ; Start computation for z term:
  408. ;---------------------------------------------------------------------------
  409. fld DWORD PTR [input][_X_]
  410. fmul DWORD PTR [eax][__MATRIX_M02] ; z1 y y x
  411. ;
  412. ; OVERLAP -- compute add for previous result
  413. ;
  414. fxch ST(1) ; y z1 y x
  415. fadd DWORD PTR [eax][__MATRIX_M31] ; y z1 y x
  416. ;
  417. fld DWORD PTR [input][_Y_]
  418. fmul DWORD PTR [eax][__MATRIX_M12] ; z2 y z1 y x
  419. fxch ST(1) ; y z2 z1 y x
  420. faddp ST(3),ST(0) ; z2 z1 y x
  421. ;---------------------------------------------------------------------------
  422. ; Start computation for w term:
  423. ;---------------------------------------------------------------------------
  424. fld DWORD PTR [input][_X_]
  425. fmul DWORD PTR [eax][__MATRIX_M03] ; w1 z z y x
  426. ;
  427. ; OVERLAP -- compute add for previous result
  428. ;
  429. fxch ST(1)
  430. fadd DWORD PTR [eax][__MATRIX_M32] ; z w1 z y x
  431. ;
  432. fxch ST(1) ; w1 z z y x
  433. fld DWORD PTR [input][_Y_]
  434. fmul DWORD PTR [eax][__MATRIX_M13] ; w2 w1 z z y x
  435. ;
  436. ; OVERLAP -- compute final z
  437. ;
  438. fxch ST(2) ; z w1 w2 z y x
  439. faddp ST(3), ST(0) ; w1 w2 z y x
  440. ;
  441. ;
  442. ; OVERLAP -- store final x
  443. ;
  444. fxch ST(4) ; x w2 z y w1
  445. fstp DWORD PTR [result][_X_]
  446. ;
  447. ; OVERLAP -- compute add for previous result
  448. ;
  449. fadd DWORD PTR [eax][__MATRIX_M33] ; w2 z y w1
  450. fxch ST(2) ; y z w2 w1
  451. ;
  452. ; OVERLAP -- store final y
  453. ;
  454. fstp DWORD PTR [result][_Y_] ; z w2 w1
  455. ;
  456. ; finish up
  457. ;
  458. fxch ST(1) ; w2 z w1
  459. faddp ST(2), ST(0) ; z w
  460. fstp DWORD PTR [result][_Z_] ; w
  461. fstp DWORD PTR [result][_W_] ; (empty)
  462. ENDM
  463. ;------------------------------Public-Routine------------------------------
  464. ;
  465. ; Avoid some transformation computations by knowing that the incoming
  466. ; vertex has z=0 and w=1. The w column of the matrix is [0 0 0 1].
  467. ;
  468. ; res->x = x*m->matrix[0][0] + y*m->matrix[1][0] + m->matrix[3][0];
  469. ; res->y = x*m->matrix[0][1] + y*m->matrix[1][1] + m->matrix[3][1];
  470. ; res->z = x*m->matrix[0][2] + y*m->matrix[1][2] + m->matrix[3][2];
  471. ; res->w = ((__GLfloat) 1.0);
  472. ;
  473. ; History:
  474. ; Thu 28-Sep-1995 -by- Otto Berkes [ottob]
  475. ; Wrote it.
  476. ;--------------------------------------------------------------------------
  477. __GL_ASM_XFORM2_W MACRO input, result
  478. ;EAX = m->matrix
  479. ;EDX = v[]
  480. ;---------------------------------------------------------------------------
  481. ; Start computation for x term:
  482. ;---------------------------------------------------------------------------
  483. fld DWORD PTR [input][_X_] ; x1
  484. fmul DWORD PTR [eax][__MATRIX_M00]
  485. fld DWORD PTR [input][_Y_] ; x2 x1
  486. fmul DWORD PTR [eax][__MATRIX_M10]
  487. ;---------------------------------------------------------------------------
  488. ; Start computation for y term:
  489. ;---------------------------------------------------------------------------
  490. fld DWORD PTR [input][_X_]
  491. fmul DWORD PTR [eax][__MATRIX_M01] ; y1 x x
  492. ;
  493. ; OVERLAP -- compute second add for previous term
  494. ;
  495. fxch ST(1) ; x y1 x
  496. fadd DWORD PTR [eax][__MATRIX_M30] ; x y1 x
  497. fxch ST(1) ; y1 x x
  498. fld DWORD PTR [input][_Y_]
  499. fmul DWORD PTR [eax][__MATRIX_M11] ; y2 y1 x x
  500. ;
  501. ; OVERLAP -- compute previous final term
  502. ;
  503. fxch ST(2) ; x y1 y2 x
  504. faddp ST(3),ST(0) ; y1 y2 x
  505. ;
  506. fadd DWORD PTR [eax][__MATRIX_M31] ; y2 y1 x
  507. ;---------------------------------------------------------------------------
  508. ; Start computation for z term:
  509. ;---------------------------------------------------------------------------
  510. fld DWORD PTR [input][_X_]
  511. fmul DWORD PTR [eax][__MATRIX_M02] ; z1 y y x
  512. ;
  513. ; OVERLAP -- compute add for previous result
  514. ;
  515. fxch ST(1) ; y z1 y x
  516. faddp ST(2),ST(0) ; z1 y x
  517. ;
  518. fld DWORD PTR [input][_Y_]
  519. fmul DWORD PTR [eax][__MATRIX_M12] ; z2 z1 y x
  520. fxch ST(1) ; z1 z2 y x
  521. fadd DWORD PTR [eax][__MATRIX_M32] ; z2 z1 y x
  522. ;
  523. ; OVERLAP -- finish up
  524. ;
  525. fxch ST(2) ; y z1 z2 x
  526. fstp DWORD PTR [result][_Y_] ; z1 z2 x
  527. faddp ST(1),ST(0) ; z x
  528. fxch ST(1) ; x z
  529. fstp DWORD PTR [result][_X_] ; z
  530. mov DWORD PTR [result][_W_], __FLOAT_ONE
  531. fstp DWORD PTR [result][_Z_] ; (empty)
  532. ENDM
  533. ;------------------------------Public-Routine------------------------------
  534. ;
  535. ; Avoid some transformation computations by knowing that the incoming
  536. ; vertex has w=1. The w column of the matrix is [0 0 0 1].
  537. ;
  538. ; res->x = x*m->matrix[0][0] + y*m->matrix[1][0] + z*m->matrix[2][0]
  539. ; + m->matrix[3][0];
  540. ; res->y = x*m->matrix[0][1] + y*m->matrix[1][1] + z*m->matrix[2][1]
  541. ; + m->matrix[3][1];
  542. ; res->z = x*m->matrix[0][2] + y*m->matrix[1][2] + z*m->matrix[2][2]
  543. ; + m->matrix[3][2];
  544. ; res->w = ((__GLfloat) 1.0);
  545. ;
  546. ; History:
  547. ; Thu 28-Sep-1995 -by- Otto Berkes [ottob]
  548. ; Wrote it.
  549. ;--------------------------------------------------------------------------
  550. __GL_ASM_XFORM3_W MACRO input, result
  551. ;EAX = m->matrix
  552. ;EDX = v[]
  553. ;---------------------------------------------------------------------------
  554. ; Start computation for x term:
  555. ;---------------------------------------------------------------------------
  556. fld DWORD PTR [input][_X_] ; x1
  557. fmul DWORD PTR [eax][__MATRIX_M00]
  558. fld DWORD PTR [input][_Y_] ; x2 x1
  559. fmul DWORD PTR [eax][__MATRIX_M10]
  560. fld DWORD PTR [input][_Z_] ; x3 x2 x1
  561. fmul DWORD PTR [eax][__MATRIX_M20]
  562. fxch ST(2) ; x1 x2 x3
  563. fadd DWORD PTR [eax][__MATRIX_M30] ; x3 x1 x2
  564. ;---------------------------------------------------------------------------
  565. ; Start computation for y term:
  566. ;---------------------------------------------------------------------------
  567. fld DWORD PTR [input][_X_]
  568. fmul DWORD PTR [eax][__MATRIX_M01] ; y1 x x x
  569. ;
  570. ; OVERLAP -- compute second add for previous term
  571. ;
  572. fxch ST(1) ; x y1 x x
  573. faddp ST(2),ST(0) ; y1 x x
  574. ;
  575. fld DWORD PTR [input][_Y_]
  576. fmul DWORD PTR [eax][__MATRIX_M11] ; y2 y1 x x
  577. ;
  578. ; OVERLAP -- compute previous final term
  579. ;
  580. fxch ST(2) ; x y1 y2 x
  581. faddp ST(3),ST(0) ; y1 y2 x
  582. ;
  583. fld DWORD PTR [input][_Z_]
  584. fmul DWORD PTR [eax][__MATRIX_M21] ; y3 y1 y2 x
  585. fxch ST(1) ; y1 y3 y2 x
  586. fadd DWORD PTR [eax][__MATRIX_M31] ; y3 y2 y1 x
  587. ;---------------------------------------------------------------------------
  588. ; Start computation for z term:
  589. ;---------------------------------------------------------------------------
  590. fld DWORD PTR [input][_X_]
  591. fmul DWORD PTR [eax][__MATRIX_M02] ; z1 y y y x
  592. ;
  593. ; OVERLAP -- compute second add for previous result
  594. ;
  595. fxch ST(1) ; y z1 y y x
  596. faddp ST(2),ST(0) ; z1 y y x
  597. ;
  598. fld DWORD PTR [input][_Y_]
  599. fmul DWORD PTR [eax][__MATRIX_M12] ; z2 z1 y y x
  600. ;
  601. ; OVERLAP -- compute previous final result
  602. ;
  603. fxch ST(2) ; y z1 z2 y x
  604. faddp ST(3),ST(0) ; z1 z2 y x
  605. ;
  606. fld DWORD PTR [input][_Z_]
  607. fmul DWORD PTR [eax][__MATRIX_M22] ; z3 z1 z2 y x
  608. fxch ST(1) ; z1 z3 z2 y x
  609. fadd DWORD PTR [eax][__MATRIX_M32] ; z3 z2 z1 y x
  610. fxch ST(1) ; z2 z3 z1 y x
  611. faddp ST(2),ST(0) ; z1 z2 y x
  612. ;
  613. ; finish up
  614. ;
  615. fxch ST(2) ; y z2 z1 x
  616. fstp DWORD PTR [result][_Y_] ; z2 z1 x
  617. faddp ST(1), ST(0) ; z x
  618. fxch ST(1) ; x z
  619. fstp DWORD PTR [result][_X_] ; z
  620. mov DWORD PTR [result][_W_], __FLOAT_ONE
  621. fstp DWORD PTR [result][_Z_] ; (empty)
  622. ENDM
  623. ;------------------------------Public-Routine------------------------------
  624. ;
  625. ; Avoid some transformation computations by knowing that we're
  626. ; only doing the 3x3 used for normals.
  627. ;
  628. ; res->x = x*m->matrix[0][0] + y*m->matrix[1][0] + z*m->matrix[2][0];
  629. ; res->y = x*m->matrix[0][1] + y*m->matrix[1][1] + z*m->matrix[2][1];
  630. ; res->z = x*m->matrix[0][2] + y*m->matrix[1][2] + z*m->matrix[2][2];
  631. ;
  632. ; History:
  633. ; Fri 29-July-1996 -by- Otto Berkes [ottob]
  634. ; Wrote it.
  635. ;--------------------------------------------------------------------------
  636. __GL_ASM_XFORM3x3 MACRO input, result
  637. ;EAX = m->matrix
  638. ;EDX = v[]
  639. ;---------------------------------------------------------------------------
  640. ; Start computation for x term:
  641. ;---------------------------------------------------------------------------
  642. fld DWORD PTR [input][_X_] ; x1
  643. fmul DWORD PTR [eax][__MATRIX_M00]
  644. fld DWORD PTR [input][_Y_] ; x2 x1
  645. fmul DWORD PTR [eax][__MATRIX_M10]
  646. fld DWORD PTR [input][_Z_] ; x3 x2 x1
  647. fmul DWORD PTR [eax][__MATRIX_M20]
  648. ;---------------------------------------------------------------------------
  649. ; Start computation for y term:
  650. ;---------------------------------------------------------------------------
  651. fld DWORD PTR [input][_X_]
  652. fmul DWORD PTR [eax][__MATRIX_M01] ; y1 x x x
  653. ;
  654. ; OVERLAP -- compute second add for previous term
  655. ;
  656. fxch ST(1) ; x y1 x x
  657. faddp ST(2),ST(0) ; y1 x x
  658. ;
  659. fld DWORD PTR [input][_Y_]
  660. fmul DWORD PTR [eax][__MATRIX_M11] ; y2 y1 x x
  661. ;
  662. ; OVERLAP -- compute previous final term
  663. ;
  664. fxch ST(2) ; x y1 y2 x
  665. faddp ST(3),ST(0) ; y1 y2 x
  666. ;
  667. fld DWORD PTR [input][_Z_]
  668. fmul DWORD PTR [eax][__MATRIX_M21] ; y3 y1 y2 x
  669. ;---------------------------------------------------------------------------
  670. ; Start computation for z term:
  671. ;---------------------------------------------------------------------------
  672. fld DWORD PTR [input][_X_]
  673. fmul DWORD PTR [eax][__MATRIX_M02] ; z1 y y y x
  674. ;
  675. ; OVERLAP -- compute second add for previous result
  676. ;
  677. fxch ST(1) ; y z1 y y x
  678. faddp ST(2),ST(0) ; z1 y y x
  679. ;
  680. fld DWORD PTR [input][_Y_]
  681. fmul DWORD PTR [eax][__MATRIX_M12] ; z2 z1 y y x
  682. ;
  683. ; OVERLAP -- compute previous final result
  684. ;
  685. fxch ST(2) ; y z1 z2 y x
  686. faddp ST(3),ST(0) ; z1 z2 y x
  687. ;
  688. fld DWORD PTR [input][_Z_]
  689. fmul DWORD PTR [eax][__MATRIX_M22] ; z3 z1 z2 y x
  690. fxch ST(1) ; z1 z3 z2 y x
  691. faddp ST(2),ST(0) ; z1 z2 y x
  692. ;
  693. ; finish up
  694. ;
  695. fxch ST(2) ; y z2 z1 x
  696. fstp DWORD PTR [result][_Y_] ; z2 z1 x
  697. faddp ST(1), ST(0) ; z x
  698. fxch ST(1) ; x z
  699. fstp DWORD PTR [result][_X_] ; z
  700. fstp DWORD PTR [result][_Z_] ; (empty)
  701. ENDM
  702. ;------------------------------Public-Routine------------------------------
  703. ;
  704. ; Full 4x4 transformation. The w column of the matrix is [0 0 0 1].
  705. ;
  706. ; if (w == ((__GLfloat) 1.0)) {
  707. ; __glXForm3_W(res, v, m);
  708. ; } else {
  709. ; res->x = x*m->matrix[0][0] + y*m->matrix[1][0] + z*m->matrix[2][0]
  710. ; + w*m->matrix[3][0];
  711. ; res->y = x*m->matrix[0][1] + y*m->matrix[1][1] + z*m->matrix[2][1]
  712. ; + w*m->matrix[3][1];
  713. ; res->z = x*m->matrix[0][2] + y*m->matrix[1][2] + z*m->matrix[2][2]
  714. ; + w*m->matrix[3][2];
  715. ; res->w = w;
  716. ; }
  717. ;
  718. ; History:
  719. ; Thu 28-Sep-1995 -by- Otto Berkes [ottob]
  720. ; Wrote it.
  721. ;--------------------------------------------------------------------------
  722. __GL_ASM_XFORM4_W MACRO input, result
  723. ;EAX = m->matrix
  724. ;EDX = v[]
  725. ;---------------------------------------------------------------------------
  726. ; Start computation for x term:
  727. ;---------------------------------------------------------------------------
  728. fld DWORD PTR [input][_X_] ; x1
  729. fmul DWORD PTR [eax][__MATRIX_M00]
  730. fld DWORD PTR [input][_Y_] ; x2 x1
  731. fmul DWORD PTR [eax][__MATRIX_M10]
  732. fld DWORD PTR [input][_Z_] ; x3 x2 x1
  733. fmul DWORD PTR [eax][__MATRIX_M20]
  734. fld DWORD PTR [input][_W_] ; x4 x3 x2 x1
  735. fmul DWORD PTR [eax][__MATRIX_M30]
  736. ;---------------------------------------------------------------------------
  737. ; Start computation for y term:
  738. ;---------------------------------------------------------------------------
  739. fld DWORD PTR [input][_X_]
  740. fmul DWORD PTR [eax][__MATRIX_M01] ; y1 x x x x
  741. ;
  742. ; OVERLAP -- compute first add for previous term
  743. ;
  744. fxch ST(1) ; x y1 x x x
  745. faddp ST(2),ST(0) ; y1 x x x
  746. ;
  747. fld DWORD PTR [input][_Y_]
  748. fmul DWORD PTR [eax][__MATRIX_M11] ; y2 y1 x x x
  749. ;
  750. ; OVERLAP -- compute second add for previous term
  751. ;
  752. fxch ST(2) ; x y1 y2 x x
  753. faddp ST(3),ST(0) ; y1 y2 x x
  754. ;
  755. fld DWORD PTR [input][_Z_]
  756. fmul DWORD PTR [eax][__MATRIX_M21] ; y3 y1 y2 x x
  757. ;
  758. ; OVERLAP -- compute previous final term
  759. ;
  760. fxch ST(3) ; x y1 y2 y3 x
  761. faddp ST(4),ST(0) ; y1 y2 y3 x
  762. ;
  763. fld DWORD PTR [input][_W_] ; y4 y1 y2 y3 x
  764. fmul DWORD PTR [eax][__MATRIX_M31]
  765. ;---------------------------------------------------------------------------
  766. ; Start computation for z term:
  767. ;---------------------------------------------------------------------------
  768. fld DWORD PTR [input][_X_]
  769. fmul DWORD PTR [eax][__MATRIX_M02] ; z1 y y y y x
  770. ;
  771. ; OVERLAP -- compute first add for previous term
  772. ;
  773. fxch ST(1) ; y z1 y y y x
  774. faddp ST(2),ST(0) ; z1 y y y x
  775. ;
  776. fld DWORD PTR [input][_Y_]
  777. fmul DWORD PTR [eax][__MATRIX_M12] ; z2 z1 y y y x
  778. ;
  779. ; OVERLAP -- compute second add for previous term
  780. ;
  781. fxch ST(2) ; y z1 z2 y y x
  782. faddp ST(3),ST(0) ; z1 z2 y y x
  783. fld DWORD PTR [input][_Z_]
  784. fmul DWORD PTR [eax][__MATRIX_M22] ; z3 z1 z2 y y x
  785. ;
  786. ; OVERLAP -- compute previous final term
  787. ;
  788. fxch ST(1) ; z1 z3 z2 y y x
  789. faddp ST(2), ST(0) ; z1 z2 y y x
  790. ;
  791. fxch ST(2) ; y z1 z2 y x
  792. faddp ST(3),ST(0) ; z1 z2 y x
  793. ;
  794. fld DWORD PTR [input][_W_] ; z3 z2 z1 y x
  795. fmul DWORD PTR [eax][__MATRIX_M32]
  796. fxch ST(1) ; z2 z3 z1 y x
  797. faddp ST(2), ST(0) ; z1 z2 y x
  798. ;
  799. ; OVERLAP -- store final y
  800. ;
  801. fxch ST(2) ; y z1 z2 x
  802. fstp DWORD PTR [result][_Y_] ; z1 z2 x
  803. faddp ST(1), ST(0) ; z x
  804. fxch ST(1) ; x z
  805. fstp DWORD PTR [result][_X_] ; z
  806. push DWORD PTR [input][_W_]
  807. fstp DWORD PTR [result][_Z_] ; (empty)
  808. pop DWORD PTR [result][_W_]
  809. ENDM
  810. ;------------------------------Public-Routine------------------------------
  811. ;
  812. ; Avoid some transformation computations by knowing that the incoming
  813. ; vertex has z=0 and w=1.
  814. ;
  815. ; The matrix looks like:
  816. ; | . . 0 0 |
  817. ; | . . 0 0 |
  818. ; | 0 0 . 0 |
  819. ; | . . . 1 |
  820. ;
  821. ; res->x = x*m->matrix[0][0] + y*m->matrix[1][0] + m->matrix[3][0];
  822. ; res->y = x*m->matrix[0][1] + y*m->matrix[1][1] + m->matrix[3][1];
  823. ; res->z = m->matrix[3][2];
  824. ; res->w = ((__GLfloat) 1.0);
  825. ;
  826. ; History:
  827. ; Thu 28-Sep-1995 -by- Otto Berkes [ottob]
  828. ; Wrote it.
  829. ;--------------------------------------------------------------------------
  830. __GL_ASM_XFORM2_2DW MACRO input, result
  831. ;EAX = m->matrix
  832. ;EDX = v[]
  833. ;---------------------------------------------------------------------------
  834. ; Start computation for x term:
  835. ;---------------------------------------------------------------------------
  836. fld DWORD PTR [input][_X_] ; x1
  837. fmul DWORD PTR [eax][__MATRIX_M00]
  838. fld DWORD PTR [input][_Y_] ; x2 x1
  839. fmul DWORD PTR [eax][__MATRIX_M10]
  840. fxch ST(1) ; x1 x2
  841. fadd DWORD PTR [eax][__MATRIX_M30]
  842. ;---------------------------------------------------------------------------
  843. ; Start computation for y term:
  844. ;---------------------------------------------------------------------------
  845. fld DWORD PTR [input][_X_]
  846. fmul DWORD PTR [eax][__MATRIX_M01] ; y1 x x
  847. ;
  848. ; OVERLAP -- compute add for previous result
  849. ;
  850. fxch ST(1) ; x y1 x
  851. faddp ST(2),ST(0) ; w1 z
  852. ;
  853. fld DWORD PTR [input][_Y_]
  854. fmul DWORD PTR [eax][__MATRIX_M11] ; y2 y1 x
  855. ;
  856. ; OVERLAP -- store final x
  857. ;
  858. fxch ST(2) ; x y1 y2
  859. fstp DWORD PTR [result][_X_] ; y1 y2
  860. ;
  861. fadd DWORD PTR [eax][__MATRIX_M31] ; y2 y1
  862. ;
  863. ; Not much we can do for the last term in the pipe...
  864. push DWORD PTR [eax][__MATRIX_M32]
  865. faddp ST(1),ST(0) ; y
  866. pop DWORD PTR [result][_Z_]
  867. mov DWORD PTR [result][_W_], __FLOAT_ONE
  868. fstp DWORD PTR [result][_Y_] ; (empty)
  869. ENDM
  870. ;------------------------------Public-Routine------------------------------
  871. ;
  872. ; Avoid some transformation computations by knowing that the incoming
  873. ; vertex has w=1.
  874. ;
  875. ; The matrix looks like:
  876. ; | . . 0 0 |
  877. ; | . . 0 0 |
  878. ; | 0 0 . 0 |
  879. ; | . . . 1 |
  880. ;
  881. ; res->x = x*m->matrix[0][0] + y*m->matrix[1][0] + m->matrix[3][0];
  882. ; res->y = x*m->matrix[0][1] + y*m->matrix[1][1] + m->matrix[3][1];
  883. ; res->z = z*m->matrix[2][2] + m->matrix[3][2];
  884. ; res->w = ((__GLfloat) 1.0);
  885. ;
  886. ; History:
  887. ; Thu 28-Sep-1995 -by- Otto Berkes [ottob]
  888. ; Wrote it.
  889. ;--------------------------------------------------------------------------
  890. __GL_ASM_XFORM3_2DW MACRO input, result
  891. ;EAX = m->matrix
  892. ;EDX = v[]
  893. ;---------------------------------------------------------------------------
  894. ; Start computation for x term:
  895. ;---------------------------------------------------------------------------
  896. fld DWORD PTR [input][_X_] ; x1
  897. fmul DWORD PTR [eax][__MATRIX_M00]
  898. fld DWORD PTR [input][_Y_] ; x2 x1
  899. fmul DWORD PTR [eax][__MATRIX_M10]
  900. fxch ST(1) ; x1 x2
  901. fadd DWORD PTR [eax][__MATRIX_M30]
  902. ;---------------------------------------------------------------------------
  903. ; Start computation for y term:
  904. ;---------------------------------------------------------------------------
  905. fld DWORD PTR [input][_X_]
  906. fmul DWORD PTR [eax][__MATRIX_M01] ; y1 x x
  907. ;
  908. ; OVERLAP -- compute add for previous result
  909. ;
  910. fxch ST(1) ; x y1 x
  911. faddp ST(2),ST(0) ; w1 z
  912. ;
  913. fld DWORD PTR [input][_Y_]
  914. fmul DWORD PTR [eax][__MATRIX_M11] ; y2 y1 x
  915. ;
  916. ; OVERLAP -- store final x
  917. ;
  918. fxch ST(2) ; x y1 y2
  919. fstp DWORD PTR [result][_X_] ; y1 y2
  920. ;
  921. fadd DWORD PTR [eax][__MATRIX_M31] ; y2 y1
  922. ;---------------------------------------------------------------------------
  923. ; Start computation for z term:
  924. ;---------------------------------------------------------------------------
  925. fld DWORD PTR [input][_Z_]
  926. fmul DWORD PTR [eax][__MATRIX_M22] ; z y y
  927. ;
  928. ; OVERLAP -- compute add for previous result
  929. ;
  930. fxch ST(1) ; y z y
  931. faddp ST(2),ST(0) ; z y
  932. fadd DWORD PTR [eax][__MATRIX_M32] ; z y
  933. mov DWORD PTR [result][_W_], __FLOAT_ONE
  934. fstp DWORD PTR [result][_Z_] ; y
  935. fstp DWORD PTR [result][_Y_] ; (empty)
  936. ENDM
  937. ;------------------------------Public-Routine------------------------------
  938. ;
  939. ; Full 4x4 transformation.
  940. ;
  941. ; The matrix looks like:
  942. ; | . . 0 0 |
  943. ; | . . 0 0 |
  944. ; | 0 0 . 0 |
  945. ; | . . . 1 |
  946. ;
  947. ; if (w == ((__GLfloat) 1.0)) {
  948. ; __glXForm3_2DW(res, v, m);
  949. ; } else {
  950. ; res->x = x*m->matrix[0][0] + y*m->matrix[1][0] + w*m->matrix[3][0];
  951. ; res->y = x*m->matrix[0][1] + y*m->matrix[1][1] + w*m->matrix[3][1];
  952. ; res->z = z*m->matrix[2][2] + w*m->matrix[3][2];
  953. ; res->w = w;
  954. ; }
  955. ;
  956. ; History:
  957. ; Thu 28-Sep-1995 -by- Otto Berkes [ottob]
  958. ; Wrote it.
  959. ;--------------------------------------------------------------------------
  960. __GL_ASM_XFORM4_2DW MACRO input, result
  961. ;EAX = m->matrix
  962. ;EDX = v[]
  963. ;---------------------------------------------------------------------------
  964. ; Start computation for x term:
  965. ;---------------------------------------------------------------------------
  966. fld DWORD PTR [input][_X_] ; x1
  967. fmul DWORD PTR [eax][__MATRIX_M00]
  968. fld DWORD PTR [input][_Y_] ; x2 x1
  969. fmul DWORD PTR [eax][__MATRIX_M10]
  970. fld DWORD PTR [input][_W_] ; x3 x2 x1
  971. fmul DWORD PTR [eax][__MATRIX_M30]
  972. fxch ST(2) ; x1 x2 x3
  973. faddp ST(1), ST ; x1+x2 x3
  974. fld DWORD PTR [input][_X_] ; y1 x1+x2 x3
  975. fmul DWORD PTR [eax][__MATRIX_M01]
  976. fld DWORD PTR [input][_Y_] ; y2 y1 x1+x2 x3
  977. fmul DWORD PTR [eax][__MATRIX_M11]
  978. fxch ST(2) ; x1+x2 y1 y2 x3
  979. faddp ST(3), ST ; y1 y2 X
  980. fld DWORD PTR [input][_W_] ; y3 y1 y2 X
  981. fmul DWORD PTR [eax][__MATRIX_M31]
  982. fxch ST(1) ; y1 y3 y2 X
  983. faddp ST(2), ST ; y3 y1+y2 X
  984. fld DWORD PTR [input][_Z_] ; z1 y3 y1+y2 X
  985. fmul DWORD PTR [eax][__MATRIX_M22]
  986. fld DWORD PTR [input][_W_] ; z2 z1 y3 y1+y2 X
  987. fmul DWORD PTR [eax][__MATRIX_M32]
  988. fxch ST(2) ; y3 z1 z2 y1+y2 X
  989. faddp ST(3), ST ; z1 z2 Y X
  990. fxch ST(3) ; X z2 Y z1
  991. fstp DWORD PTR [result][_X_] ; z2 Y z2
  992. faddp ST(2), ST ; Y Z
  993. fstp DWORD PTR [result][_Y_]
  994. fstp DWORD PTR [result][_Z_]
  995. push DWORD PTR [input][_W_]
  996. pop DWORD PTR [result][_W_]
  997. ENDM
  998. ;------------------------------Public-Routine------------------------------
  999. ;
  1000. ; Avoid some transformation computations by knowing that the incoming
  1001. ; vertex has z=0 and w=1.
  1002. ;
  1003. ; The matrix looks like:
  1004. ; | . 0 0 0 |
  1005. ; | 0 . 0 0 |
  1006. ; | 0 0 . 0 |
  1007. ; | . . . 1 |
  1008. ;
  1009. ; res->x = x*m->matrix[0][0] + m->matrix[3][0];
  1010. ; res->y = y*m->matrix[1][1] + m->matrix[3][1];
  1011. ; res->z = m->matrix[3][2];
  1012. ; res->w = ((__GLfloat) 1.0);
  1013. ;
  1014. ; History:
  1015. ; Thu 28-Sep-1995 -by- Otto Berkes [ottob]
  1016. ; Wrote it.
  1017. ;--------------------------------------------------------------------------
  1018. __GL_ASM_XFORM2_2DNRW MACRO input, result
  1019. ;EAX = m->matrix
  1020. ;EDX = v[]
  1021. ;---------------------------------------------------------------------------
  1022. ; Start computation for x term:
  1023. ;---------------------------------------------------------------------------
  1024. fld DWORD PTR [input][_X_] ; x
  1025. fmul DWORD PTR [eax][__MATRIX_M00]
  1026. ;---------------------------------------------------------------------------
  1027. ; Start computation for y term:
  1028. ;---------------------------------------------------------------------------
  1029. fld DWORD PTR [input][_Y_]
  1030. fmul DWORD PTR [eax][__MATRIX_M11] ; y x
  1031. ;
  1032. ; OVERLAP -- compute add for previous result
  1033. ;
  1034. fxch ST(1) ; x y
  1035. fadd DWORD PTR [eax][__MATRIX_M30] ; x y
  1036. fxch ST(1) ; y x
  1037. mov DWORD PTR [result][_W_], __FLOAT_ONE
  1038. fadd DWORD PTR [eax][__MATRIX_M31] ; y x
  1039. ; Not much we can do for the last term in the pipe...
  1040. push DWORD PTR [eax][__MATRIX_M32]
  1041. fstp DWORD PTR [result][_Y_] ; x
  1042. fstp DWORD PTR [result][_X_] ; (empty)
  1043. pop DWORD PTR [result][_Z_]
  1044. ENDM
  1045. ;------------------------------Public-Routine------------------------------
  1046. ;
  1047. ; Avoid some transformation computations by knowing that the incoming
  1048. ; vertex has w=1.
  1049. ;
  1050. ; The matrix looks like:
  1051. ; | . 0 0 0 |
  1052. ; | 0 . 0 0 |
  1053. ; | 0 0 . 0 |
  1054. ; | . . . 1 |
  1055. ;
  1056. ; res->x = x*m->matrix[0][0] + m->matrix[3][0];
  1057. ; res->y = y*m->matrix[1][1] + m->matrix[3][1];
  1058. ; res->z = z*m->matrix[2][2] + m->matrix[3][2];
  1059. ; res->w = ((__GLfloat) 1.0);
  1060. ;
  1061. ; History:
  1062. ; Thu 28-Sep-1995 -by- Otto Berkes [ottob]
  1063. ; Wrote it.
  1064. ;--------------------------------------------------------------------------
  1065. __GL_ASM_XFORM3_2DNRW MACRO input, result
  1066. ;EAX = m->matrix
  1067. ;EDX = v[]
  1068. ;---------------------------------------------------------------------------
  1069. ; Start computation for x term:
  1070. ;---------------------------------------------------------------------------
  1071. fld DWORD PTR [input][_X_] ; x
  1072. fmul DWORD PTR [eax][__MATRIX_M00]
  1073. ;---------------------------------------------------------------------------
  1074. ; Start computation for y term:
  1075. ;---------------------------------------------------------------------------
  1076. fld DWORD PTR [input][_Y_]
  1077. fmul DWORD PTR [eax][__MATRIX_M11] ; y x
  1078. ;
  1079. ; OVERLAP -- compute add for previous result
  1080. ;
  1081. fxch ST(1) ; x y
  1082. fadd DWORD PTR [eax][__MATRIX_M30] ; x y
  1083. fxch ST(1) ; y x
  1084. ;---------------------------------------------------------------------------
  1085. ; Start computation for z term:
  1086. ;---------------------------------------------------------------------------
  1087. fld DWORD PTR [input][_Z_]
  1088. fmul DWORD PTR [eax][__MATRIX_M22] ; z y x
  1089. ;
  1090. ; OVERLAP -- compute add for previous result
  1091. ;
  1092. fxch ST(1) ; y z x
  1093. fadd DWORD PTR [eax][__MATRIX_M31] ; y z x
  1094. fxch ST(2) ; x z y
  1095. fstp DWORD PTR [result][_X_] ; z y
  1096. fadd DWORD PTR [eax][__MATRIX_M32] ; z y
  1097. fxch ST(1) ; y z
  1098. fstp DWORD PTR [result][_Y_] ; z
  1099. mov DWORD PTR [result][_W_], __FLOAT_ONE
  1100. fstp DWORD PTR [result][_Z_] ; (empty)
  1101. ENDM
  1102. ;------------------------------Public-Routine------------------------------
  1103. ;
  1104. ; Full 4x4 transformation.
  1105. ;
  1106. ; The matrix looks like:
  1107. ; | . 0 0 0 |
  1108. ; | 0 . 0 0 |
  1109. ; | 0 0 . 0 |
  1110. ; | . . . 1 |
  1111. ;
  1112. ; if (w == ((__GLfloat) 1.0)) {
  1113. ; __glXForm3_2DNRW(res, v, m);
  1114. ; } else {
  1115. ; res->x = x*m->matrix[0][0] + w*m->matrix[3][0];
  1116. ; res->y = y*m->matrix[1][1] + w*m->matrix[3][1];
  1117. ; res->z = z*m->matrix[2][2] + w*m->matrix[3][2];
  1118. ; res->w = w;
  1119. ; }
  1120. ;
  1121. ; History:
  1122. ; Thu 28-Sep-1995 -by- Otto Berkes [ottob]
  1123. ; Wrote it.
  1124. ;--------------------------------------------------------------------------
  1125. __GL_ASM_XFORM4_2DNRW MACRO input, result
  1126. ;EAX = m->matrix
  1127. ;EDX = v[]
  1128. ;---------------------------------------------------------------------------
  1129. ; Start computation for x term:
  1130. ;---------------------------------------------------------------------------
  1131. fld DWORD PTR [input][_X_] ; x
  1132. fmul DWORD PTR [eax][__MATRIX_M00]
  1133. fld DWORD PTR [input][_W_] ; x x
  1134. fmul DWORD PTR [eax][__MATRIX_M30]
  1135. ;---------------------------------------------------------------------------
  1136. ; Start computation for y term:
  1137. ;---------------------------------------------------------------------------
  1138. fld DWORD PTR [input][_Y_]
  1139. fmul DWORD PTR [eax][__MATRIX_M11] ; y x x
  1140. ;
  1141. ; OVERLAP -- compute add for previous result
  1142. ;
  1143. fxch ST(1) ; x y x
  1144. faddp ST(2),ST(0) ; y x
  1145. fld DWORD PTR [input][_W_]
  1146. fmul DWORD PTR [eax][__MATRIX_M31] ; y y x
  1147. fxch ST(2) ; x y y
  1148. fstp DWORD PTR [result][_X_] ; y y
  1149. ;---------------------------------------------------------------------------
  1150. ; Start computation for z term:
  1151. ;---------------------------------------------------------------------------
  1152. fld DWORD PTR [input][_Z_]
  1153. fmul DWORD PTR [eax][__MATRIX_M22] ; z y y
  1154. fxch ST(1) ; y z y
  1155. faddp ST(2), ST(0) ; z y
  1156. fld DWORD PTR [input][_W_] ; z z y
  1157. fmul DWORD PTR [eax][__MATRIX_M32]
  1158. fxch ST(2) ; y z z
  1159. fstp DWORD PTR [result][_Y_] ; z z
  1160. faddp ST(1), ST(0) ; z
  1161. push DWORD PTR [input][_W_]
  1162. fstp DWORD PTR [result][_Z_] ; (empty)
  1163. pop DWORD PTR [result][_W_]
  1164. ENDM
  1165. SINGLE_COORD_NEEDED = 1
  1166. ifdef SINGLE_COORD_NEEDED
  1167. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1168. ;;
  1169. ;; Generate single-coordinate matrix routines.
  1170. ;;
  1171. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1172. ;; ifdef __GL_ASM_XFORM3
  1173. ;------------------------------Public-Routine------------------------------
  1174. ;
  1175. ; void FASTCALL __glXForm3(__GLcoord *res, const __GLfloat v[3],
  1176. ; const __GLmatrix *m)
  1177. ;
  1178. ;--------------------------------------------------------------------------
  1179. public @__glXForm3@12
  1180. @__glXForm3@12 proc near
  1181. PROF_ENTRY
  1182. DBGPRINTID str1
  1183. mov eax, DWORD PTR [esp + 4]
  1184. __GL_ASM_XFORM3 <edx>, <ecx>
  1185. ret 4
  1186. @__glXForm3@12 endp
  1187. ;; endif ; __GL_ASM_XFORM3
  1188. ;; ifdef __GL_ASM_XFORM4
  1189. ;------------------------------Public-Routine------------------------------
  1190. ;
  1191. ; void FASTCALL __glXForm4(__GLcoord *res, const __GLfloat v[4],
  1192. ; const __GLmatrix *m)
  1193. ;
  1194. ;--------------------------------------------------------------------------
  1195. public @__glXForm4@12
  1196. @__glXForm4@12 proc near
  1197. PROF_ENTRY
  1198. DBGPRINTID str2
  1199. cmp DWORD PTR [edx][_W_],__FLOAT_ONE ; special case w = 1
  1200. je @__glXForm3@12
  1201. mov eax, DWORD PTR [esp + 4]
  1202. __GL_ASM_XFORM4 <edx>, <ecx>
  1203. ret 4
  1204. @__glXForm4@12 endp
  1205. ;; endif ; __GL_ASM_XFORM4
  1206. ;; ifdef __GL_ASM_XFORM2
  1207. ;------------------------------Public-Routine------------------------------
  1208. ;
  1209. ; void FASTCALL __glXForm2(__GLcoord *res, const __GLfloat v[2],
  1210. ; const __GLmatrix *m)
  1211. ;
  1212. ;--------------------------------------------------------------------------
  1213. public @__glXForm2@12
  1214. @__glXForm2@12 proc near
  1215. PROF_ENTRY
  1216. DBGPRINTID str3
  1217. mov eax, DWORD PTR [esp + 4]
  1218. __GL_ASM_XFORM2 <edx>, <ecx>
  1219. ret 4
  1220. @__glXForm2@12 endp
  1221. ;; endif ; __GL_ASM_XFORM2
  1222. ;; ifdef __GL_ASM_XFORM2_W
  1223. ;------------------------------Public-Routine------------------------------
  1224. ;
  1225. ; void FASTCALL __glXForm2_W(__GLcoord *res, const __GLfloat v[2],
  1226. ; const __GLmatrix *m)
  1227. ;
  1228. ;--------------------------------------------------------------------------
  1229. public @__glXForm2_W@12
  1230. @__glXForm2_W@12 proc near
  1231. PROF_ENTRY
  1232. DBGPRINTID str4
  1233. mov eax, DWORD PTR [esp + 4]
  1234. __GL_ASM_XFORM2_W <edx>, <ecx>
  1235. ret 4
  1236. @__glXForm2_W@12 endp
  1237. ;; endif ; __GL_ASM_XFORM2_W
  1238. ;; ifdef __GL_ASM_XFORM3_W
  1239. ;------------------------------Public-Routine------------------------------
  1240. ;
  1241. ; void FASTCALL __glXForm3_W(__GLcoord *res, const __GLfloat v[3],
  1242. ; const __GLmatrix *m)
  1243. ;
  1244. ;--------------------------------------------------------------------------
  1245. public @__glXForm3_W@12
  1246. @__glXForm3_W@12 proc near
  1247. PROF_ENTRY
  1248. DBGPRINTID str5
  1249. mov eax, DWORD PTR [esp + 4]
  1250. __GL_ASM_XFORM3_W <edx>, <ecx>
  1251. ret 4
  1252. @__glXForm3_W@12 endp
  1253. ;; endif ; __GL_ASM_XFORM3_W
  1254. ;; ifdef __GL_ASM_XFORM3x3
  1255. ;------------------------------Public-Routine------------------------------
  1256. ;
  1257. ; void FASTCALL __glXForm3x3(__GLcoord *res, const __GLfloat v[3],
  1258. ; const __GLmatrix *m)
  1259. ;
  1260. ;--------------------------------------------------------------------------
  1261. public @__glXForm3x3@12
  1262. @__glXForm3x3@12 proc near
  1263. PROF_ENTRY
  1264. DBGPRINTID str15
  1265. mov eax, DWORD PTR [esp + 4]
  1266. __GL_ASM_XFORM3x3 <edx>, <ecx>
  1267. ret 4
  1268. @__glXForm3x3@12 endp
  1269. ;; endif ; __GL_ASM_XFORM3X3
  1270. ;; ifdef __GL_ASM_XFORM4_W
  1271. ;------------------------------Public-Routine------------------------------
  1272. ;
  1273. ; void FASTCALL __glXForm4_W(__GLcoord *res, const __GLfloat v[3],
  1274. ; const __GLmatrix *m)
  1275. ;
  1276. ;--------------------------------------------------------------------------
  1277. public @__glXForm4_W@12
  1278. @__glXForm4_W@12 proc near
  1279. PROF_ENTRY
  1280. DBGPRINTID str6
  1281. cmp DWORD PTR [edx][_W_],__FLOAT_ONE ; special case w = 1
  1282. je @__glXForm3_W@12
  1283. mov eax, DWORD PTR [esp + 4]
  1284. __GL_ASM_XFORM4_W <edx>, <ecx>
  1285. ret 4
  1286. @__glXForm4_W@12 endp
  1287. ;; endif ; __GL_ASM_XFORM4_W
  1288. ;; ifdef __GL_ASM_XFORM2_2DW
  1289. ;------------------------------Public-Routine------------------------------
  1290. ;
  1291. ; void FASTCALL __glXForm2_2DW(__GLcoord *res, const __GLfloat v[2],
  1292. ; const __GLmatrix *m)
  1293. ;
  1294. ;--------------------------------------------------------------------------
  1295. public @__glXForm2_2DW@12
  1296. @__glXForm2_2DW@12 proc near
  1297. PROF_ENTRY
  1298. DBGPRINTID str7
  1299. mov eax, DWORD PTR [esp + 4]
  1300. __GL_ASM_XFORM2_2DW <edx>, <ecx>
  1301. ret 4
  1302. @__glXForm2_2DW@12 endp
  1303. ;; endif ; __GL_ASM_XFORM2_2DW
  1304. ;; ifdef __GL_ASM_XFORM3_2DW
  1305. ;------------------------------Public-Routine------------------------------
  1306. ;
  1307. ; void FASTCALL __glXForm3_2DW(__GLcoord *res, const __GLfloat v[3],
  1308. ; const __GLmatrix *m)
  1309. ;
  1310. ;--------------------------------------------------------------------------
  1311. public @__glXForm3_2DW@12
  1312. @__glXForm3_2DW@12 proc near
  1313. PROF_ENTRY
  1314. DBGPRINTID str8
  1315. mov eax, DWORD PTR [esp + 4]
  1316. __GL_ASM_XFORM3_2DW <edx>, <ecx>
  1317. ret 4
  1318. @__glXForm3_2DW@12 endp
  1319. ;; endif ; __GL_ASM_XFORM3_2DW
  1320. ;; ifdef __GL_ASM_XFORM4_2DW
  1321. ;------------------------------Public-Routine------------------------------
  1322. ;
  1323. ; void FASTCALL __glXForm4_2DW(__GLcoord *res, const __GLfloat v[4],
  1324. ; const __GLmatrix *m)
  1325. ;--------------------------------------------------------------------------
  1326. public @__glXForm4_2DW@12
  1327. @__glXForm4_2DW@12 proc near
  1328. PROF_ENTRY
  1329. DBGPRINTID str9
  1330. cmp DWORD PTR [edx][_W_],__FLOAT_ONE ; special case w = 1
  1331. je @__glXForm3_2DW@12
  1332. mov eax, DWORD PTR [esp + 4]
  1333. __GL_ASM_XFORM4_2DW <edx>, <ecx>
  1334. ret 4
  1335. @__glXForm4_2DW@12 endp
  1336. ;; endif ; __GL_ASM_XFORM4_2DW
  1337. ;; ifdef __GL_ASM_XFORM2_2DNRW
  1338. ;------------------------------Public-Routine------------------------------
  1339. ;
  1340. ; void FASTCALL __glXForm2_2DNRW(__GLcoord *res, const __GLfloat v[2],
  1341. ; const __GLmatrix *m)
  1342. ;
  1343. ;--------------------------------------------------------------------------
  1344. public @__glXForm2_2DNRW@12
  1345. @__glXForm2_2DNRW@12 proc near
  1346. PROF_ENTRY
  1347. DBGPRINTID str10
  1348. mov eax, DWORD PTR [esp + 4]
  1349. __GL_ASM_XFORM2_2DNRW <edx>, <ecx>
  1350. ret 4
  1351. @__glXForm2_2DNRW@12 endp
  1352. ;; endif ; __GL_ASM_XFORM2_2DNRW
  1353. ;; ifdef __GL_ASM_XFORM3_2DNRW
  1354. ;------------------------------Public-Routine------------------------------
  1355. ;
  1356. ; void FASTCALL __glXForm3_2DNRW(__GLcoord *res, const __GLfloat v[3],
  1357. ; const __GLmatrix *m)
  1358. ;
  1359. ;--------------------------------------------------------------------------
  1360. public @__glXForm3_2DNRW@12
  1361. @__glXForm3_2DNRW@12 proc near
  1362. PROF_ENTRY
  1363. DBGPRINTID str11
  1364. mov eax, DWORD PTR [esp + 4]
  1365. __GL_ASM_XFORM3_2DNRW <edx>, <ecx>
  1366. ret 4
  1367. @__glXForm3_2DNRW@12 endp
  1368. ;; endif ; __GL_ASM_XFORM3_2DNRW
  1369. ;; ifdef __GL_ASM_XFORM4_2DNRW
  1370. ;------------------------------Public-Routine------------------------------
  1371. ;
  1372. ; void FASTCALL __glXForm4_2DNRW(__GLcoord *res, const __GLfloat v[4],
  1373. ; const __GLmatrix *m)
  1374. ;
  1375. ;--------------------------------------------------------------------------
  1376. public @__glXForm4_2DNRW@12
  1377. @__glXForm4_2DNRW@12 proc near
  1378. PROF_ENTRY
  1379. DBGPRINTID str12
  1380. cmp DWORD PTR [edx][_W_],__FLOAT_ONE ; special case w = 1
  1381. je @__glXForm3_2DNRW@12
  1382. mov eax, DWORD PTR [esp + 4]
  1383. __GL_ASM_XFORM4_2DNRW <edx>, <ecx>
  1384. ret 4
  1385. @__glXForm4_2DNRW@12 endp
  1386. ;; endif ; __GL_ASM_XFORM4_2DNRW
  1387. endif ;;SINGLE_COORD_NEEDED
  1388. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1389. ;;
  1390. ;; Now, generate batched-coordinate matrix routines.
  1391. ;;
  1392. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  1393. ;------------------------------Public-Routine------------------------------
  1394. ; Macro used in all batch routines
  1395. ;
  1396. ; ecx = coordinate address
  1397. ; edx = coordinate address for last vertex
  1398. ; [esp+4] = matrix
  1399. ;
  1400. ; name = function name
  1401. ; func = function name to transform a single vertex
  1402. ;
  1403. ; Used registers:
  1404. ; eax, ecx, edx
  1405. ;
  1406. glXFormBatch MACRO name, func
  1407. public @&name&@12
  1408. @&name&@12 PROC NEAR
  1409. PROF_ENTRY
  1410. DBGPRINTID str1
  1411. mov eax, DWORD PTR [esp + 4]
  1412. vertexLoop:
  1413. func <ecx>, <ecx>
  1414. add ecx, sizeof_POLYDATA
  1415. cmp ecx, edx
  1416. jbe vertexLoop
  1417. ret 4
  1418. @&name&@12 ENDP
  1419. ENDM
  1420. ;-------------------------------------------------------------------------
  1421. ;
  1422. ; Macro to normalize a normal
  1423. ;
  1424. ; Input:
  1425. ; regPD - register with POLYDATA address
  1426. ; reg2 - any register (will be destroed)
  1427. ; reg3 - any register (will be destroed)
  1428. ; tmpmem1 - memory offset for temporary data
  1429. ; tmpmem2 - memory offset for temporary data
  1430. ;
  1431. ; Algoriphm
  1432. ;
  1433. ; Computation of 1/sqrt(x), where x is a positive floating point number
  1434. ;
  1435. ; x = 2^(E-127)*M, E - exponent (8 bits), M - mantissa (23 bits)
  1436. ;
  1437. ; 1/sqrt(x) = 1/sqrt(2^(E-127)*M)
  1438. ;
  1439. ; if E is odd, i.e. E = 2*n + 1 then we have
  1440. ;
  1441. ; x = 1/sqrt(2^(2*n + 1 - 127)*M) = 1/sqrt(2^(2*(n-63))*M) = 1/[2^(n-63)*sqrt(M)] =
  1442. ;
  1443. ; = 2^(63-n)/sqrt(M)
  1444. ;
  1445. ; if E is even, i.e. E = 2*n then we have
  1446. ;
  1447. ; x = 1/sqrt(2^(2*n - 127)*M) = 1/sqrt(2^(2*n-126)*M/2) = 1/[2^(n-63)*sqrt(M/2)] =
  1448. ;
  1449. ; = 2^(63-n)/sqrt(M/2)
  1450. ;
  1451. ; Using K bits of M and 1 lowest bit of E we can make a K+1 bits index (I) into a table.
  1452. ; Actually mantissa will have K+1 bits, because of one hidden bit.
  1453. ;
  1454. ; Table will store 1/sqrt(mantissa) or 1/sqrt(mantissa/2), depending on lowest E bit.
  1455. ;
  1456. ; if I == 0 .. 2^(K+1)-1, then
  1457. ;
  1458. ; Table[I] = (float)(1.0/sqrt(((i & (2^K - 1))/(2^K)+1.0))), if I & 2^(K) != 0
  1459. ;
  1460. ; Table[I] = (float)(1.0/sqrt(((i & (2^K - 1))/(2^K)+1.0)/2.0)), if I & 2^(K) == 0
  1461. ;
  1462. ; 1.0 is added because of the hidden bit in mantissa.
  1463. ;
  1464. ;
  1465. ;
  1466. ; 31 23 22 0
  1467. ;---------------------------------------------------
  1468. ;! ! ! K bits ! !
  1469. ;---------------------------------------------------
  1470. ; !
  1471. ; -------------- bit from exponent
  1472. ;
  1473. ; Bit from the exponent and K bits from mantissa are shifted right by 23 - K bits and
  1474. ; this is the index to a table.
  1475. ;
  1476. ; n = E div 2
  1477. ;
  1478. ; To multiply by 2^(63-n) we can just add (63-n) << MANTISSA_BITS to a result
  1479. ; from the table. (Or we can substruct (n-63) << MANTISSA_BITS).
  1480. ;
  1481. ; void FASTCALL __glNormalize(float* result, float* source)
  1482. ;
  1483. ; edx = result
  1484. ; ecx = source
  1485. ;
  1486. MANTISSA_SIZE equ 24 ; number if mantissa bits in fp value
  1487. MANTISSA_BITS equ (MANTISSA_SIZE - 1)
  1488. MANTISSA_MASK equ ((1 SHL MANTISSA_BITS) - 1)
  1489. EXPONENT_MASK equ (-1 AND (NOT MANTISSA_MASK))
  1490. K equ 9 ; K used bits of mantissa
  1491. NORMALIZE macro regPD, reg2, reg3, tmpmem1, tmpmem2
  1492. fld DWORD PTR [regPD+PD_normal]
  1493. fmul DWORD PTR [regPD+PD_normal] ;; x
  1494. fld DWORD PTR [regPD+PD_normal+4]
  1495. fmul DWORD PTR [regPD+PD_normal+4] ;; y x
  1496. fld DWORD PTR [regPD+PD_normal+8]
  1497. fmul DWORD PTR [regPD+PD_normal+8] ;; z y x
  1498. fxch ST(2) ;; x y z
  1499. faddp ST(1), ST ;; xy z
  1500. faddp ST(1), ST ;; xyz
  1501. fstp tmpmem1 ;; length
  1502. mov reg2, tmpmem1
  1503. cmp reg2, __FLOAT_ONE
  1504. je @continue
  1505. mov reg3, reg2
  1506. and reg3, MANTISSA_MASK SHL 1 + 1
  1507. shr reg2, 1
  1508. shr reg3, MANTISSA_BITS - K
  1509. and reg2, EXPONENT_MASK
  1510. mov reg3, [_invSqrtTable + reg3*4]
  1511. sub reg2, 63 SHL MANTISSA_BITS
  1512. sub reg3, reg2
  1513. mov tmpmem2, reg3 ;; 1/sqrt(length)
  1514. fld DWORD PTR [regPD+PD_normal]
  1515. fmul tmpmem2 ;; x
  1516. fld DWORD PTR [regPD+PD_normal+4]
  1517. fmul tmpmem2 ;; y x
  1518. fld DWORD PTR [regPD+PD_normal+8]
  1519. fmul tmpmem2 ;; z y x
  1520. fxch ST(2) ;; x y z
  1521. fstp DWORD PTR [regPD+PD_normal]
  1522. fstp DWORD PTR [regPD+PD_normal+4]
  1523. fstp DWORD PTR [regPD+PD_normal+8]
  1524. @continue:
  1525. ENDM
  1526. ;------------------------------------------------------------
  1527. ; Macro used in all batch routines for normal transformation
  1528. ;
  1529. ; ecx = pointer to a polyarray
  1530. ; edx = matrix
  1531. ;
  1532. ; name = function name
  1533. ; func = function name to transform a single vertex
  1534. ;
  1535. ; Used registers:
  1536. ; eax, ecx, edx
  1537. ;
  1538. glXFormBatchNormal MACRO name, func
  1539. public @&name&@8
  1540. @&name&@8 PROC NEAR
  1541. PROF_ENTRY
  1542. DBGPRINTID str1
  1543. mov eax, edx ; matrix pointer
  1544. mov edx, [ecx+PA_pdNextVertex]
  1545. mov ecx, [ecx+PA_pd0]
  1546. @vertexLoop:
  1547. test DWORD PTR [ecx+PD_flags], POLYDATA_NORMAL_VALID
  1548. jz @nextVertex
  1549. func <ecx+PD_normal>, <ecx+PD_normal>
  1550. @nextVertex:
  1551. add ecx, sizeof_POLYDATA
  1552. cmp ecx, edx
  1553. jl @vertexLoop
  1554. ret
  1555. @&name&@8 ENDP
  1556. ENDM
  1557. ;------------------------------------------------------------
  1558. ; Macro used in all batch routines for normal transformation
  1559. ; with normalization
  1560. ;
  1561. ; ecx = pointer to a polyarray
  1562. ; edx = matrix
  1563. ;
  1564. ; name = function name
  1565. ; func = function name to transform a single vertex
  1566. ;
  1567. ; Used registers:
  1568. ; eax, ecx, edx
  1569. ;
  1570. glXFormBatchNormalN MACRO name, func
  1571. public @&name&@8
  1572. @&name&@8 PROC NEAR
  1573. PROF_ENTRY
  1574. DBGPRINTID str1
  1575. push ebp
  1576. mov ebp, esp
  1577. sub esp, 8
  1578. push ebx
  1579. push esi
  1580. mov eax, edx ; matrix pointer
  1581. mov edx, [ecx+PA_pdNextVertex]
  1582. mov ecx, [ecx+PA_pd0]
  1583. @vertexLoop:
  1584. test DWORD PTR [ecx+PD_flags], POLYDATA_NORMAL_VALID
  1585. jz @nextVertex
  1586. func <ecx+PD_normal>, <ecx+PD_normal>
  1587. NORMALIZE <ecx>, <ebx>, <esi>, <DWORD PTR -4[ebp]>, <DWORD PTR -8[ebp]>
  1588. @nextVertex:
  1589. add ecx, sizeof_POLYDATA
  1590. cmp ecx, edx
  1591. jl @vertexLoop
  1592. pop esi
  1593. pop ebx
  1594. mov esp, ebp
  1595. pop ebp
  1596. ret
  1597. @&name&@8 ENDP
  1598. ENDM
  1599. ;------------------------------Public-Routine------------------------------
  1600. ;
  1601. ; void FASTCALL __glXForm3Batch(__GLcoord *start, __GLcoord *end,
  1602. ; const __GLmatrix *m)
  1603. ;
  1604. ;; ifdef __GL_ASM_XFORM3
  1605. glXformBatch __glXForm3Batch, __GL_ASM_XFORM3
  1606. ;; endif ; __GL_ASM_XFORM3
  1607. ;------------------------------Public-Routine------------------------------
  1608. ;
  1609. ; void FASTCALL __glXForm4Batch(__GLcoord *start, __GLcoord *end,
  1610. ; const __GLmatrix *m)
  1611. ;
  1612. ;; ifdef __GL_ASM_XFORM4
  1613. glXformBatch __glXForm4Batch, __GL_ASM_XFORM4
  1614. ;; endif ; __GL_ASM_XFORM4
  1615. ;------------------------------Public-Routine------------------------------
  1616. ;
  1617. ; void FASTCALL __glXForm2Batch(__GLcoord *start, __GLcoord *end,
  1618. ; const __GLmatrix *m)
  1619. ;
  1620. ;; ifdef __GL_ASM_XFORM2
  1621. glXformBatch __glXForm2Batch, __GL_ASM_XFORM2
  1622. ;; endif ; __GL_ASM_XFORM2
  1623. ;------------------------------Public-Routine------------------------------
  1624. ;
  1625. ; void FASTCALL __glXForm2_WBatch(__GLcoord *start, __GLcoord *end,
  1626. ; const __GLmatrix *m)
  1627. ;
  1628. ;; ifdef __GL_ASM_XFORM2_W
  1629. glXformBatch __glXForm2_WBatch, __GL_ASM_XFORM2_W
  1630. ;; endif ; __GL_ASM_XFORM2_W
  1631. ;------------------------------Public-Routine------------------------------
  1632. ;
  1633. ; void FASTCALL __glXForm3_WBatch(__GLcoord *start, __GLcoord *end,
  1634. ; const __GLmatrix *m)
  1635. ;
  1636. ;; ifdef __GL_ASM_XFORM3_W
  1637. glXformBatch __glXForm3_WBatch, __GL_ASM_XFORM3_W
  1638. ;; endif ; __GL_ASM_XFORM3_W
  1639. ;------------------------------Public-Routine------------------------------
  1640. ;
  1641. ; void FASTCALL __glXForm3x3Batch(__GLcoord *start, __GLcoord *end,
  1642. ; const __GLmatrix *m)
  1643. ;
  1644. ;; ifdef __GL_ASM_XFORM3x3
  1645. glXformBatch __glXForm3x3Batch, __GL_ASM_XFORM3x3
  1646. ;; endif ; __GL_ASM_XFORM3X3
  1647. ;------------------------------Public-Routine------------------------------
  1648. ;
  1649. ; void FASTCALL __glXForm3x3BatchNormal(POLYARRAY* pa, const __GLmatrix *m)
  1650. ;
  1651. ;; ifdef __GL_ASM_XFORM3x3Normal
  1652. glXformBatchNormal __glXForm3x3BatchNormal, __GL_ASM_XFORM3x3
  1653. ;; endif ; __GL_ASM_XFORM3X3
  1654. ;------------------------------Public-Routine------------------------------
  1655. ;
  1656. ; void FASTCALL __glXForm3x3BatchNormalN(POLYARRAY* pa, const __GLmatrix *m)
  1657. ;
  1658. ;; ifdef __GL_ASM_XFORM3x3Normal
  1659. glXformBatchNormalN __glXForm3x3BatchNormalN, __GL_ASM_XFORM3x3
  1660. ;; endif ; __GL_ASM_XFORM3X3
  1661. ;------------------------------Public-Routine------------------------------
  1662. ;
  1663. ; void FASTCALL __glXForm4_WBatch(__GLcoord *start, __GLcoord *end,
  1664. ; const __GLmatrix *m)
  1665. ;
  1666. ;; ifdef __GL_ASM_XFORM4_W
  1667. glXformBatch __glXForm4_WBatch, __GL_ASM_XFORM4_W
  1668. ;; endif ; __GL_ASM_XFORM4_W
  1669. ;------------------------------Public-Routine------------------------------
  1670. ;
  1671. ; void FASTCALL __glXForm2_2DWBatch(__GLcoord *start, __GLcoord *end,
  1672. ; const __GLmatrix *m)
  1673. ;
  1674. ;; ifdef __GL_ASM_XFORM2_2DW
  1675. glXformBatch __glXForm2_2DWBatch, __GL_ASM_XFORM2_2DW
  1676. ;; endif ; __GL_ASM_XFORM2_2DW
  1677. ;------------------------------Public-Routine------------------------------
  1678. ;
  1679. ; void FASTCALL __glXForm3_2DWBatch(__GLcoord *start, __GLcoord *end,
  1680. ; const __GLmatrix *m)
  1681. ;
  1682. ;; ifdef __GL_ASM_XFORM3_2DW
  1683. glXformBatch __glXForm3_2DWBatch, __GL_ASM_XFORM3_2DW
  1684. ;; endif ; __GL_ASM_XFORM3_2DW
  1685. ;------------------------------Public-Routine------------------------------
  1686. ;
  1687. ; void FASTCALL __glXForm3_2DWBatchNormal(POLYARRAY* pa, const __GLmatrix *m)
  1688. ;
  1689. ;; ifdef __GL_ASM_XFORM3_2DW
  1690. glXformBatchNormal __glXForm3_2DWBatchNormal, __GL_ASM_XFORM3x3
  1691. ;; endif ; __GL_ASM_XFORM3_2DW
  1692. ;------------------------------Public-Routine------------------------------
  1693. ;
  1694. ; void FASTCALL __glXForm3_2DWBatchNormalN(POLYARRAY* pa, const __GLmatrix *m)
  1695. ;
  1696. ;; ifdef __GL_ASM_XFORM3_2DW
  1697. glXformBatchNormalN __glXForm3_2DWBatchNormalN, __GL_ASM_XFORM3x3
  1698. ;; endif ; __GL_ASM_XFORM3_2DW
  1699. ;------------------------------Public-Routine------------------------------
  1700. ;
  1701. ; void FASTCALL __glXForm4_2DWBatch(__GLcoord *start, __GLcoord *end,
  1702. ; const __GLmatrix *m)
  1703. ;; ifdef __GL_ASM_XFORM4_2DW
  1704. glXformBatch __glXForm4_2DWBatch, __GL_ASM_XFORM4_2DW
  1705. ;; endif ; __GL_ASM_XFORM4_2DW
  1706. ;------------------------------Public-Routine------------------------------
  1707. ;
  1708. ; void FASTCALL __glXForm2_2DNRWBatch(__GLcoord *start, __GLcoord *end,
  1709. ; const __GLmatrix *m)
  1710. ;
  1711. ;; ifdef __GL_ASM_XFORM2_2DNRW
  1712. glXformBatch __glXForm2_2DNRWBatch, __GL_ASM_XFORM2_2DNRW
  1713. ;; endif ; __GL_ASM_XFORM2_2DNRW
  1714. ;------------------------------Public-Routine------------------------------
  1715. ;
  1716. ; void FASTCALL __glXForm3_2DNRWBatch(__GLcoord *start, __GLcoord *end,
  1717. ; const __GLmatrix *m)
  1718. ;
  1719. ;; ifdef __GL_ASM_XFORM3_2DNRW
  1720. glXformBatch __glXForm3_2DNRWBatch, __GL_ASM_XFORM3_2DNRW
  1721. ;; endif ; __GL_ASM_XFORM3_2DNRW
  1722. ;------------------------------Public-Routine------------------------------
  1723. ;
  1724. ; void FASTCALL __glXForm3_2DNRWBatchNormal(POLYARRAY* pa, const __GLmatrix *m)
  1725. ;
  1726. ;; ifdef __GL_ASM_XFORM3_2DNRW
  1727. glXformBatchNormal __glXForm3_2DNRWBatchNormal, __GL_ASM_XFORM3x3
  1728. ;; endif ; __GL_ASM_XFORM3_2DNRW
  1729. ;------------------------------Public-Routine------------------------------
  1730. ;
  1731. ; void FASTCALL __glXForm3_2DNRWBatchNormalN(POLYARRAY* pa, const __GLmatrix *m)
  1732. ;
  1733. ;; ifdef __GL_ASM_XFORM3_2DNRW
  1734. glXformBatchNormalN __glXForm3_2DNRWBatchNormalN, __GL_ASM_XFORM3x3
  1735. ;; endif ; __GL_ASM_XFORM3_2DNRW
  1736. ;------------------------------Public-Routine------------------------------
  1737. ;
  1738. ; void FASTCALL __glXForm4_2DNRWBatch(__GLcoord *start, __GLcoord *end,
  1739. ; const __GLmatrix *m)
  1740. ;
  1741. ;; ifdef __GL_ASM_XFORM4_2DNRW
  1742. glXformBatch __glXForm4_2DNRWBatch, __GL_ASM_XFORM4_2DNRW
  1743. ;; endif ; __GL_ASM_XFORM4_2DNRW
  1744. ;-------------------------------------------------------------------------
  1745. ;
  1746. ; void FASTCALL __glNormalizeBatch(POLYARRAY* pa)
  1747. ;
  1748. ; ecx = POLYARRAY
  1749. ;
  1750. @__glNormalizeBatch@4 PROC NEAR
  1751. push ebp
  1752. mov ebp, esp
  1753. sub esp, 8
  1754. push ebx
  1755. push edx
  1756. mov edx, DWORD PTR [ecx+PA_pd0]
  1757. mov ebx, DWORD PTR [ecx+PA_pdNextVertex]
  1758. vertexLoop:
  1759. test [edx+PD_flags], POLYDATA_NORMAL_VALID
  1760. jz nextVertex
  1761. NORMALIZE <edx>, <eax>, <ecx>, <DWORD PTR -4[ebp]>, <DWORD PTR -8[ebp]>
  1762. nextVertex:
  1763. add edx, sizeof_POLYDATA
  1764. cmp edx, ebx
  1765. jl vertexLoop
  1766. pop edx
  1767. pop ebx
  1768. mov esp, ebp
  1769. pop ebp
  1770. ret 0
  1771. @__glNormalizeBatch@4 ENDP
  1772. END