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.

436 lines
10 KiB

  1. ;---------------------------Module-Header------------------------------;
  2. ; Module Name: glivtx.asm
  3. ;
  4. ; OpenGL vertex API function entries for i386.
  5. ;
  6. ; Created: 04/16/1996
  7. ; Author: Drew Bliss [drewb]
  8. ;
  9. ; Copyright (c) 1996 Microsoft Corporation
  10. ;----------------------------------------------------------------------;
  11. .386
  12. .model small,c
  13. assume cs:FLAT,ds:FLAT,es:FLAT,ss:FLAT
  14. assume fs:nothing,gs:nothing
  15. .xlist
  16. include ks386.inc
  17. include gli386.inc
  18. PROFILE = 0
  19. include profile.inc
  20. .list
  21. OPTION PROLOGUE:NONE
  22. OPTION EPILOGUE:NONE
  23. @PolyArrayFlushPartialPrimitive@0 PROTO SYSCALL
  24. @glcltNormal3f_NotInBegin@16 PROTO SYSCALL
  25. @glcltTexCoord4f_NotInBegin@24 PROTO SYSCALL
  26. @glcltColor4f_InRGBA_NotInBegin@28 PROTO SYSCALL
  27. IF POLYARRAY_IN_BEGIN GT 255
  28. .ERR POLYARRAY_IN_BEGIN too large
  29. ENDIF
  30. IF POLYARRAY_VERTEX3 GT 255
  31. .ERR POLYARRAY_VERTEX3 too large
  32. ENDIF
  33. IF POLYDATA_VERTEX3 GT 255
  34. .ERR POLYDATA_VERTEX3 too large
  35. ENDIF
  36. IF POLYARRAY_VERTEX2 GT 255
  37. .ERR POLYARRAY_VERTEX2 too large
  38. ENDIF
  39. IF POLYDATA_VERTEX2 GT 255
  40. .ERR POLYDATA_VERTEX2 too large
  41. ENDIF
  42. IF POLYDATA_NORMAL_VALID GT 255
  43. .ERR POLYDATA_NORMAL_VALID too large
  44. ENDIF
  45. .data
  46. extrn dwTlsOffset:DWORD
  47. .code
  48. ; Gets the current POLYARRAY pointer in eax
  49. ; These functions cannot rely on registers being set by
  50. ; the dispatch functions because they are also called directly
  51. ; in the display list code
  52. IFDEF _WIN95_
  53. GET_PATEB MACRO
  54. mov eax, fs:[PcTeb]
  55. add eax, DWORD PTR [dwTlsOffset]
  56. mov eax, [eax]
  57. add eax, GtiPaTeb
  58. ENDM
  59. GL_SETUP MACRO
  60. mov eax, fs:[PcTeb]
  61. add eax, DWORD PTR [dwTlsOffset]
  62. mov eax, [eax]
  63. mov ebx, [eax+GtiSectionInfo]
  64. add eax, GtiPaTeb
  65. ENDM
  66. ELSE
  67. GET_PATEB MACRO
  68. mov eax, fs:[TeglPaTeb]
  69. ENDM
  70. GL_SETUP MACRO
  71. mov eax, fs:[TeglPaTeb]
  72. mov ebx, fs:[TeglSectionInfo]
  73. ENDM
  74. ENDIF
  75. PA_VERTEX_STACK_USAGE EQU 4
  76. ; Handles two and three-element vertex calls
  77. PA_VERTEX_23 MACRO base, offs, ret_n, pop_ebp, elts, pa_flag, pd_flag
  78. LOCAL NotInBegin, Flush
  79. GET_PATEB
  80. push esi
  81. mov ecx, [eax+PA_flags]
  82. mov esi, [eax+PA_pdNextVertex]
  83. test ecx, POLYARRAY_IN_BEGIN
  84. lea edx, [esi+sizeof_POLYDATA]
  85. jz NotInBegin
  86. or ecx, pa_flag
  87. mov [eax+PA_pdNextVertex], edx
  88. mov [eax+PA_flags], ecx
  89. mov ecx, [esi+PD_flags]
  90. mov [edx+PD_flags], 0
  91. or ecx, pd_flag
  92. mov eax, [eax+PA_pdFlush]
  93. mov [esi+PD_flags], ecx
  94. cmp esi, eax
  95. mov edx, [base+offs]
  96. mov ecx, [base+offs+4]
  97. IF elts GT 2
  98. mov eax, [base+offs+8]
  99. ELSE
  100. ; xor clears flags so don't use it here
  101. mov eax, 0
  102. ENDIF
  103. mov [esi+PD_obj], edx
  104. mov [esi+PD_obj+4], ecx
  105. mov [esi+PD_obj+8], eax
  106. mov DWORD PTR [esi+PD_obj+12], __FLOAT_ONE
  107. jge Flush
  108. NotInBegin:
  109. pop esi
  110. IF pop_ebp
  111. pop ebp
  112. ENDIF
  113. ret ret_n
  114. Flush:
  115. call @PolyArrayFlushPartialPrimitive@0
  116. pop esi
  117. IF pop_ebp
  118. pop ebp
  119. ENDIF
  120. ret ret_n
  121. ENDM
  122. glcltVertex2f@8 PROC PUBLIC
  123. PROF_ENTRY
  124. PA_VERTEX_23 esp, 4+PA_VERTEX_STACK_USAGE, 8, 0, 2, \
  125. POLYARRAY_VERTEX2, POLYDATA_VERTEX2
  126. glcltVertex2f@8 ENDP
  127. glcltVertex2fv@4 PROC PUBLIC
  128. PROF_ENTRY
  129. push ebp
  130. mov ebp, [esp+8]
  131. PA_VERTEX_23 ebp, 0, 4, 1, 2, \
  132. POLYARRAY_VERTEX2, POLYDATA_VERTEX2
  133. glcltVertex2fv@4 ENDP
  134. glcltVertex3f@12 PROC PUBLIC
  135. PROF_ENTRY
  136. PA_VERTEX_23 esp, 4+PA_VERTEX_STACK_USAGE, 12, 0, 3, \
  137. POLYARRAY_VERTEX3, POLYDATA_VERTEX3
  138. glcltVertex3f@12 ENDP
  139. glcltVertex3fv@4 PROC PUBLIC
  140. PROF_ENTRY
  141. push ebp
  142. mov ebp, [esp+8]
  143. PA_VERTEX_23 ebp, 0, 4, 1, 3, \
  144. POLYARRAY_VERTEX3, POLYDATA_VERTEX3
  145. glcltVertex3fv@4 ENDP
  146. PA_NORMAL_STACK_USAGE EQU 4
  147. ; Handles three-element normal calls
  148. PA_NORMAL_3 MACRO base, offs, ret_n, pop_ebp
  149. LOCAL NotInBegin, Flush
  150. GET_PATEB
  151. push esi
  152. mov ecx, [eax+PA_flags]
  153. mov esi, [eax+PA_pdNextVertex]
  154. test ecx, POLYARRAY_IN_BEGIN
  155. mov edx, [base+offs]
  156. jz NotInBegin
  157. mov ecx, [esi+PD_flags]
  158. mov [eax+PA_pdCurNormal], esi
  159. or ecx, POLYDATA_NORMAL_VALID
  160. mov eax, [base+offs+4]
  161. mov [esi+PD_flags], ecx
  162. mov ecx, [base+offs+8]
  163. mov [esi+PD_normal], edx
  164. mov [esi+PD_normal+4], eax
  165. mov [esi+PD_normal+8], ecx
  166. pop esi
  167. IF pop_ebp
  168. pop ebp
  169. ENDIF
  170. ret ret_n
  171. NotInBegin:
  172. mov ecx, eax
  173. lea edx, [base+offs]
  174. push [edx+8]
  175. push [edx+4]
  176. push [edx]
  177. call @glcltNormal3f_NotInBegin@16
  178. pop esi
  179. IF pop_ebp
  180. pop ebp
  181. ENDIF
  182. ret ret_n
  183. ENDM
  184. glcltNormal3f@12 PROC PUBLIC
  185. PROF_ENTRY
  186. PA_NORMAL_3 esp, 4+PA_NORMAL_STACK_USAGE, 12, 0
  187. glcltNormal3f@12 ENDP
  188. glcltNormal3fv@4 PROC PUBLIC
  189. PROF_ENTRY
  190. push ebp
  191. mov ebp, [esp+8]
  192. PA_NORMAL_3 ebp, 0, 4, 1
  193. glcltNormal3fv@4 ENDP
  194. PA_TEXTURE_STACK_USAGE EQU 4
  195. ; Handles two and three-element texture calls
  196. PA_TEXTURE_23 MACRO base, offs, ret_n, pop_ebp, elts, pa_flag, pd_flag
  197. LOCAL NotInBegin, Flush
  198. GET_PATEB
  199. push esi
  200. mov ecx, [eax+PA_flags]
  201. mov esi, [eax+PA_pdNextVertex]
  202. test ecx, POLYARRAY_IN_BEGIN
  203. jz NotInBegin
  204. or ecx, pa_flag
  205. mov [eax+PA_pdCurTexture], esi
  206. mov [eax+PA_flags], ecx
  207. mov ecx, [esi+PD_flags]
  208. mov eax, [base+offs]
  209. or ecx, POLYDATA_TEXTURE_VALID OR pd_flag
  210. mov edx, [base+offs+4]
  211. mov [esi+PD_flags], ecx
  212. mov [esi+PD_texture], eax
  213. IF elts GT 2
  214. mov ecx, [base+offs+8]
  215. ELSE
  216. xor ecx, ecx
  217. ENDIF
  218. mov [esi+PD_texture+4], edx
  219. mov [esi+PD_texture+8], ecx
  220. mov DWORD PTR [esi+PD_texture+12], __FLOAT_ONE
  221. pop esi
  222. IF pop_ebp
  223. pop ebp
  224. ENDIF
  225. ret ret_n
  226. NotInBegin:
  227. mov ecx, eax
  228. lea edx, [base+offs]
  229. push __FLOAT_ONE
  230. IF elts GT 2
  231. push [edx+8]
  232. ELSE
  233. push 0
  234. ENDIF
  235. push [edx+4]
  236. push [edx]
  237. mov edx, pa_flag
  238. call @glcltTexCoord4f_NotInBegin@24
  239. pop esi
  240. IF pop_ebp
  241. pop ebp
  242. ENDIF
  243. ret ret_n
  244. ENDM
  245. glcltTexCoord2f@8 PROC PUBLIC
  246. PROF_ENTRY
  247. PA_TEXTURE_23 esp, 4+PA_TEXTURE_STACK_USAGE, 8, 0, 2, \
  248. POLYARRAY_TEXTURE2, POLYDATA_DLIST_TEXTURE2
  249. glcltTexCoord2f@8 ENDP
  250. glcltTexCoord2fv@4 PROC PUBLIC
  251. PROF_ENTRY
  252. push ebp
  253. mov ebp, [esp+8]
  254. PA_TEXTURE_23 ebp, 0, 4, 1, 2, \
  255. POLYARRAY_TEXTURE2, POLYDATA_DLIST_TEXTURE2
  256. glcltTexCoord2fv@4 ENDP
  257. glcltTexCoord3f@12 PROC PUBLIC
  258. PROF_ENTRY
  259. PA_TEXTURE_23 esp, 4+PA_TEXTURE_STACK_USAGE, 12, 0, 3, \
  260. POLYARRAY_TEXTURE3, POLYDATA_DLIST_TEXTURE3
  261. glcltTexCoord3f@12 ENDP
  262. glcltTexCoord3fv@4 PROC PUBLIC
  263. PROF_ENTRY
  264. push ebp
  265. mov ebp, [esp+8]
  266. PA_TEXTURE_23 ebp, 0, 4, 1, 3, \
  267. POLYARRAY_TEXTURE3, POLYDATA_DLIST_TEXTURE3
  268. glcltTexCoord3fv@4 ENDP
  269. if POLYARRAY_CLAMP_COLOR NE 080000000h
  270. .err <Color logic assumes POLYARRAY_CLAMP_COLOR is 080000000h>
  271. endif
  272. PA_COLOR_STACK_USAGE EQU 12
  273. ; Handles three and four-element color calls
  274. PA_COLOR_34 MACRO base, offs, ret_n, pop_ebp, elts, pd_flag
  275. LOCAL NotInBegin, Flush
  276. push ebx
  277. GL_SETUP
  278. push esi
  279. push edi
  280. mov ecx, [eax+PA_flags]
  281. mov esi, [eax+PA_pdNextVertex]
  282. test ecx, POLYARRAY_IN_BEGIN
  283. jz NotInBegin
  284. IF elts GT 3
  285. fld DWORD PTR [base+offs+12]
  286. fmul DWORD PTR [ebx+GC_alphaVertexScale]
  287. ENDIF
  288. fld DWORD PTR [base+offs]
  289. mov [eax+PA_pdCurColor], esi
  290. fmul DWORD PTR [ebx+GC_redVertexScale]
  291. mov ecx, [esi+PD_flags]
  292. fld DWORD PTR [base+offs+4]
  293. or ecx, (POLYDATA_COLOR_VALID or pd_flag)
  294. fmul DWORD PTR [ebx+GC_greenVertexScale]
  295. mov [esi+PD_flags], ecx
  296. fld DWORD PTR [base+offs+8]
  297. fmul DWORD PTR [ebx+GC_blueVertexScale] ;; b g r (a)
  298. fxch ST(2) ;; r g b (a)
  299. fstp DWORD PTR [esi+PD_colors0+0]
  300. mov eax, [ebx+GC_redVertexScale]
  301. fstp DWORD PTR [esi+PD_colors0+4]
  302. mov edx, [esi+PD_colors0+0]
  303. fstp DWORD PTR [esi+PD_colors0+8]
  304. mov ecx, [ebx+GC_greenVertexScale]
  305. IF elts GT 3
  306. fstp DWORD PTR [esi+PD_colors0+12]
  307. ENDIF
  308. mov edi, [esi+PD_colors0+4]
  309. sub eax, edx
  310. sub ecx, edi
  311. or eax, edx
  312. or ecx, edi
  313. mov edx, [ebx+GC_blueVertexScale]
  314. or eax, ecx
  315. mov edi, [esi+PD_colors0+8]
  316. mov ecx, [ebx+GC_paTeb] ;; we no longer have pa, so
  317. or eax, edi ;; reload it
  318. sub edx, edi
  319. mov edi, [ebx+GC_alphaVertexScale]
  320. or eax, edx
  321. IF elts GT 3
  322. mov edx, [esi+PD_colors0+12]
  323. sub edi, edx
  324. mov edx, [ecx+PA_flags]
  325. or eax, edi
  326. ELSE
  327. mov [esi+PD_colors0+12], edi
  328. mov edx, [ecx+PA_flags]
  329. ENDIF
  330. pop edi
  331. and eax, POLYARRAY_CLAMP_COLOR
  332. pop esi
  333. or eax, edx
  334. pop ebx
  335. IF pop_ebp
  336. pop ebp
  337. ENDIF
  338. mov [ecx+PA_flags], eax
  339. ret ret_n
  340. NotInBegin:
  341. ;; ecx = gc = ebx
  342. ;; edx = pa = eax
  343. lea edi, [base+offs]
  344. mov ecx, ebx
  345. mov edx, eax
  346. IF elts GT 3
  347. push [edi+12]
  348. ELSE
  349. push __FLOAT_ONE
  350. ENDIF
  351. push [edi+8]
  352. push [edi+4]
  353. push [edi+0]
  354. push DWORD PTR POLYDATA_COLOR_VALID OR pd_flag
  355. call @glcltColor4f_InRGBA_NotInBegin@28
  356. pop edi
  357. pop esi
  358. pop ebx
  359. IF pop_ebp
  360. pop ebp
  361. ENDIF
  362. ret ret_n
  363. ENDM
  364. glcltColor3f_InRGBA@12 PROC PUBLIC
  365. PROF_ENTRY
  366. PA_COLOR_34 esp, 4+PA_COLOR_STACK_USAGE, 12, 0, 3, 0
  367. glcltColor3f_InRGBA@12 ENDP
  368. glcltColor3fv_InRGBA@4 PROC PUBLIC
  369. PROF_ENTRY
  370. push ebp
  371. mov ebp, [esp+8]
  372. PA_COLOR_34 ebp, 0, 4, 1, 3, 0
  373. glcltColor3fv_InRGBA@4 ENDP
  374. glcltColor4f_InRGBA@16 PROC PUBLIC
  375. PROF_ENTRY
  376. PA_COLOR_34 esp, 4+PA_COLOR_STACK_USAGE, 16, 0, 4, \
  377. POLYDATA_DLIST_COLOR_4
  378. glcltColor4f_InRGBA@16 ENDP
  379. glcltColor4fv_InRGBA@4 PROC PUBLIC
  380. PROF_ENTRY
  381. push ebp
  382. mov ebp, [esp+8]
  383. PA_COLOR_34 ebp, 0, 4, 1, 4, \
  384. POLYDATA_DLIST_COLOR_4
  385. glcltColor4fv_InRGBA@4 ENDP
  386. END