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.

340 lines
9.3 KiB

  1. ;---------------------------Module-Header------------------------------;
  2. ; Module Name: dl_opt.asm
  3. ;
  4. ; OpenGL display-list function entries for i386.
  5. ;
  6. ; Created: 09/20/1996
  7. ; Author: Otto Berkes [ottob]
  8. ;
  9. ; Copyright (c) 1996 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 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. __imp__OutputDebugStringA@4 PROTO SYSCALL
  25. .data
  26. ifdef DBG
  27. warningStr db 'Display list: playing back POLYDATA outside BEGIN!', 13, 10, 0
  28. endif
  29. .code
  30. __GL_PDATA_FUNC MACRO name
  31. public @&name&@8
  32. @&name&@8 PROC
  33. PROF_ENTRY
  34. mov eax, [ecx].GC_paTeb ;; eax = pa
  35. push ebx
  36. push esi
  37. push edi
  38. if __DL_PDATA_C3F
  39. mov ecx, [ecx].GC_alphaVertexScale
  40. endif
  41. @again:
  42. ;; if (pa->flags & POLYARRAY_IN_BEGIN) {
  43. ;; pd = pa->pdNextVertex++;
  44. ;; pa->flags |= __DL_PDATA_PA_FLAGS;
  45. mov ebx, [eax].PA_flags ;; ebx = flags
  46. mov esi, [eax].PA_pdNextVertex ;; esi = pd
  47. test ebx, POLYARRAY_IN_BEGIN
  48. lea edi, [esi + sizeof_POLYDATA]
  49. je @notInBegin
  50. mov [eax].PA_pdNextVertex, edi
  51. or ebx, __DL_PDATA_PA_FLAGS
  52. ;; pd->flags |= __DL_PDATA_PD_FLAGS;
  53. mov edi, [esi].PD_flags
  54. mov [eax].PA_flags, ebx
  55. or edi, __DL_PDATA_PD_FLAGS
  56. if __DL_PDATA_C3F
  57. ;; pd->color[0].a = gc->alphaVertexScale;
  58. mov [esi][PD_colors0 + 12], ecx
  59. endif
  60. ;;
  61. ;; CACHE !!!
  62. ;;
  63. ;; In the logic below, we try to fill cache lines before we need them
  64. ;; by reading into registers that to not use the contents that they
  65. ;; fetched. Unfortunatly, the data in the display list is not cached-
  66. ;; aligned, so this will be hit-and-miss. It does, however, make a
  67. ;; measurable difference.
  68. ;;
  69. if __DL_PDATA_T2F
  70. ;; pa->pdCurTexture = pd;
  71. mov [eax].PA_pdCurTexture, esi
  72. mov ecx, [edx][__DL_PDATA_TEXTURE_OFFSET + 0] ;; fill cache
  73. endif
  74. if __DL_PDATA_C3F OR __DL_PDATA_C4F
  75. ;; pa->pdCurColor = pd;
  76. mov [eax].PA_pdCurColor, esi
  77. mov ebx, [edx][__DL_PDATA_COLOR_OFFSET + 0] ;; fill cache
  78. endif
  79. if __DL_PDATA_N3F
  80. ;; pa->pdCurNormal = pd;
  81. mov [eax].PA_pdCurNormal, esi
  82. mov ecx, [edx][__DL_PDATA_NORMAL_OFFSET + 0] ;; fill cache
  83. endif
  84. if __DL_PDATA_V2F or __DL_PDATA_V3F
  85. mov ebx, [edx][__DL_PDATA_VERTEX_OFFSET + 0] ;; fill cache
  86. endif
  87. ;; finally, store pd flags:
  88. mov [esi].PD_flags, edi
  89. ;; Update pd attributes.
  90. ;; constant: esi, edi, eax, edx
  91. ;; free: ebx, ecx
  92. if __DL_PDATA_T2F
  93. ;; Texture coord
  94. ;; pd->texture.x = ((__GLcoord *) &PC[__DL_PDATA_TEXTURE_OFFSET])->x;
  95. ;; pd->texture.y = ((__GLcoord *) &PC[__DL_PDATA_TEXTURE_OFFSET])->y;
  96. ;; pd->texture.z = __glZero;
  97. ;; pd->texture.w = __glOne;
  98. mov ebx, [edx][__DL_PDATA_TEXTURE_OFFSET + 0]
  99. mov ecx, [edx][__DL_PDATA_TEXTURE_OFFSET + 4]
  100. mov [esi][PD_texture + 0 ], ebx
  101. mov [esi][PD_texture + 4 ], ecx
  102. mov DWORD PTR [esi][PD_texture + 8 ], 0
  103. mov DWORD PTR [esi][PD_texture + 12], __FLOAT_ONE;
  104. endif
  105. if __DL_PDATA_C3F
  106. ;; Color
  107. ;; pd->color[0].r = ((__GLcolor *) &PC[__DL_PDATA_COLOR_OFFSET])->r;
  108. ;; pd->color[0].g = ((__GLcolor *) &PC[__DL_PDATA_COLOR_OFFSET])->g;
  109. ;; pd->color[0].b = ((__GLcolor *) &PC[__DL_PDATA_COLOR_OFFSET])->b;
  110. mov ebx, [edx][__DL_PDATA_COLOR_OFFSET + 0]
  111. mov ecx, [edx][__DL_PDATA_COLOR_OFFSET + 4]
  112. mov edi, [edx][__DL_PDATA_COLOR_OFFSET + 8]
  113. mov [esi][PD_colors0 + 0 ], ebx
  114. mov [esi][PD_colors0 + 4 ], ecx
  115. mov [esi][PD_colors0 + 8 ], edi
  116. elseif __DL_PDATA_C4F
  117. ;; Color
  118. ;; pd->color[0] = *((__GLcolor *) &PC[__DL_PDATA_COLOR_OFFSET]);
  119. mov ebx, [edx][__DL_PDATA_COLOR_OFFSET + 0]
  120. mov ecx, [edx][__DL_PDATA_COLOR_OFFSET + 4]
  121. mov [esi][PD_colors0 + 0 ], ebx
  122. mov [esi][PD_colors0 + 4 ], ecx
  123. mov ebx, [edx][__DL_PDATA_COLOR_OFFSET + 8]
  124. mov ecx, [edx][__DL_PDATA_COLOR_OFFSET + 12]
  125. mov [esi][PD_colors0 + 8 ], ebx
  126. mov [esi][PD_colors0 + 12], ecx
  127. endif
  128. if __DL_PDATA_N3F
  129. ;; Normal
  130. ;; pd->normal.x = ((__GLcoord *) &PC[__DL_PDATA_NORMAL_OFFSET])->x;
  131. ;; pd->normal.y = ((__GLcoord *) &PC[__DL_PDATA_NORMAL_OFFSET])->y;
  132. ;; pd->normal.z = ((__GLcoord *) &PC[__DL_PDATA_NORMAL_OFFSET])->z;
  133. mov ebx, [edx][__DL_PDATA_NORMAL_OFFSET + 0]
  134. mov ecx, [edx][__DL_PDATA_NORMAL_OFFSET + 4]
  135. mov edi, [edx][__DL_PDATA_NORMAL_OFFSET + 8]
  136. mov [esi][PD_normal + 0 ], ebx
  137. mov [esi][PD_normal + 4 ], ecx
  138. mov [esi][PD_normal + 8 ], edi
  139. endif
  140. if __DL_PDATA_V2F
  141. ;; Vertex
  142. ;; pd->obj.x = ((__GLcoord *) &PC[__DL_PDATA_VERTEX_OFFSET])->x;
  143. ;; pd->obj.y = ((__GLcoord *) &PC[__DL_PDATA_VERTEX_OFFSET])->y;
  144. ;; pd->obj.z = __glZero;
  145. ;; pd->obj.w = __glOne;
  146. mov ebx, [edx][__DL_PDATA_VERTEX_OFFSET + 0]
  147. mov ecx, [edx][__DL_PDATA_VERTEX_OFFSET + 4]
  148. mov [esi][PD_obj + 0 ], ebx
  149. mov [esi][PD_obj + 4 ], ecx
  150. mov DWORD PTR [esi][PD_OBJ + 8 ], 0
  151. mov DWORD PTR [esi][PD_obj + 12], __FLOAT_ONE
  152. elseif __DL_PDATA_V3F
  153. ;; Vertex
  154. ;; pd->obj.x = ((__GLcoord *) &PC[__DL_PDATA_VERTEX_OFFSET])->x;
  155. ;; pd->obj.y = ((__GLcoord *) &PC[__DL_PDATA_VERTEX_OFFSET])->y;
  156. ;; pd->obj.z = ((__GLcoord *) &PC[__DL_PDATA_VERTEX_OFFSET])->z;
  157. ;; pd->obj.w = __glOne;
  158. mov ebx, [__DL_PDATA_VERTEX_OFFSET + 0][edx]
  159. mov ecx, [__DL_PDATA_VERTEX_OFFSET + 4][edx]
  160. mov edi, [__DL_PDATA_VERTEX_OFFSET + 8][edx]
  161. mov [esi][PD_obj + 0 ], ebx
  162. mov [esi][PD_obj + 4 ], ecx
  163. mov [esi][PD_obj + 8 ], edi
  164. mov DWORD PTR [esi][PD_obj + 12], __FLOAT_ONE
  165. endif
  166. ;; pd[1].flags = 0;
  167. ;; if (pd >= pa->pdFlush)
  168. ;; PolyArrayFlushPartialPrimitive();
  169. mov ebx, [eax].PA_pdFlush
  170. mov DWORD PTR [esi][sizeof_POLYDATA + PD_flags], 0
  171. cmp ebx, esi
  172. mov ebx, [edx - 4]
  173. mov ecx, [edx + __DL_PDATA_SIZE]
  174. ja @noFlush
  175. push esi
  176. push edi
  177. push eax
  178. push ebx
  179. push ecx
  180. push edx
  181. call @PolyArrayFlushPartialPrimitive@0
  182. pop edx
  183. pop ecx
  184. pop ebx
  185. pop eax
  186. pop edi
  187. pop esi
  188. @noFlush:
  189. cmp ebx, ecx
  190. jne @doExit
  191. lea edx, [edx + __DL_PDATA_SIZE + 4]
  192. if __DL_PDATA_C3F
  193. mov ecx, [esi][PD_colors0 + 12]
  194. endif
  195. jmp @again
  196. @doExit:
  197. lea eax, [edx + __DL_PDATA_SIZE]
  198. pop edi
  199. pop esi
  200. pop ebx
  201. ret 0
  202. @notInBegin:
  203. ifdef DBG
  204. push edx
  205. push offset warningStr
  206. call DWORD PTR __imp__OutputDebugStringA@4
  207. pop edx
  208. endif
  209. lea eax, [edx + __DL_PDATA_SIZE]
  210. pop edi
  211. pop esi
  212. pop ebx
  213. ret 0
  214. @&name&@8 ENDP
  215. ENDM
  216. ;; Define fast playback routines for PolyData records.
  217. __GLLE_POLYDATA_C3F_V3F = 0
  218. __GLLE_POLYDATA_N3F_V3F = 0
  219. __GLLE_POLYDATA_C3F_N3F_V3F = 0
  220. __GLLE_POLYDATA_C4F_N3F_V3F = 0
  221. __GLLE_POLYDATA_T2F_V3F = 0
  222. __GLLE_POLYDATA_T2F_C3F_V3F = 0
  223. __GLLE_POLYDATA_T2F_N3F_V3F = 0
  224. __GLLE_POLYDATA_T2F_C3F_N3F_V3F = 0
  225. __GLLE_POLYDATA_T2F_C4F_N3F_V3F = 0
  226. __GLLE_POLYDATA_C3F_V3F = 1
  227. include dl_pdata.inc
  228. __GL_PDATA_FUNC <__glle_PolyData_C3F_V3F>
  229. __GLLE_POLYDATA_C3F_V3F = 0
  230. __GLLE_POLYDATA_N3F_V3F = 1
  231. include dl_pdata.inc
  232. __GL_PDATA_FUNC <__glle_PolyData_N3F_V3F>
  233. __GLLE_POLYDATA_N3F_V3F = 0
  234. __GLLE_POLYDATA_C3F_N3F_V3F = 1
  235. include dl_pdata.inc
  236. __GL_PDATA_FUNC <__glle_PolyData_C3F_N3F_V3F>
  237. __GLLE_POLYDATA_C3F_N3F_V3F = 0
  238. __GLLE_POLYDATA_C4F_N3F_V3F = 1
  239. include dl_pdata.inc
  240. __GL_PDATA_FUNC <__glle_PolyData_C4F_N3F_V3F>
  241. __GLLE_POLYDATA_C4F_N3F_V3F = 0
  242. __GLLE_POLYDATA_T2F_V3F = 1
  243. include dl_pdata.inc
  244. __GL_PDATA_FUNC <__glle_PolyData_T2F_V3F>
  245. __GLLE_POLYDATA_T2F_V3F = 0
  246. __GLLE_POLYDATA_T2F_C3F_V3F = 1
  247. include dl_pdata.inc
  248. __GL_PDATA_FUNC <__glle_PolyData_T2F_C3F_V3F>
  249. __GLLE_POLYDATA_T2F_C3F_V3F = 0
  250. __GLLE_POLYDATA_T2F_N3F_V3F = 1
  251. include dl_pdata.inc
  252. __GL_PDATA_FUNC <__glle_PolyData_T2F_N3F_V3F>
  253. __GLLE_POLYDATA_T2F_N3F_V3F = 0
  254. __GLLE_POLYDATA_T2F_C3F_N3F_V3F = 1
  255. include dl_pdata.inc
  256. __GL_PDATA_FUNC <__glle_PolyData_T2F_C3F_N3F_V3F>
  257. __GLLE_POLYDATA_T2F_C3F_N3F_V3F = 0
  258. __GLLE_POLYDATA_T2F_C4F_N3F_V3F = 1
  259. include dl_pdata.inc
  260. __GL_PDATA_FUNC <__glle_PolyData_T2F_C4F_N3F_V3F>
  261. __GLLE_POLYDATA_T2F_C4F_N3F_V3F = 0
  262. end