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.

413 lines
12 KiB

  1. ;-----------------------------------------------------------------------------
  2. ;
  3. ; This file contains x86 ramp loops.
  4. ;
  5. ; Copyright (C) Microsoft Corporation, 1997.
  6. ;
  7. ; WARNING WARNING WARNING
  8. ; This assembly file generated from mas file.
  9. ; EDIT THE MAS FILE.
  10. ; I warned you.
  11. ; WARNING WARNING WARNING
  12. ;
  13. ;-----------------------------------------------------------------------------
  14. include(`m4hdr.mh')dnl
  15. define(`d_BeadMacrosOnly', `')dnl
  16. include(`rampbead.mh')dnl
  17. .386p
  18. .MODEL FLAT
  19. INCLUDE offs_acp.inc
  20. INCLUDE profile.inc
  21. .CODE
  22. PWL_PERSP_STEP_SHIFT EQU 4
  23. PWL_PERSP_STEP EQU 16
  24. define(`d_Ramp_Copy_Spans',
  25. `ifelse(eval(d_index($1, `Copy') >= 0), `1', `
  26. Ramp_$1 PROC C PUBLIC USES ebx esi edi,
  27. pCtx:DWORD
  28. LOCAL pP:DWORD, pS:DWORD
  29. LOCAL uSpans:DWORD
  30. LOCAL iSurfStep:DWORD
  31. ifelse(eval(d_index($1, `NoZTest') < 0), `1',
  32. ` LOCAL iZStep:DWORD
  33. LOCAL uZ:DWORD, iDZDX:DWORD
  34. ')dnl
  35. LOCAL pTexBits:DWORD
  36. LOCAL iShiftPitch:BYTE
  37. LOCAL uMaskU:DWORD, uMaskV:DWORD
  38. ifelse(eval(d_index($1, `_Tex') >= 0), `1', `
  39. ifelse(eval(d_index($1, `NoPersp') < 0), `1',
  40. ` LOCAL iDUDX:DWORD, iDVDX:DWORD
  41. LOCAL iU1:DWORD, iV1:DWORD
  42. LOCAL iU2:DWORD, iV2:DWORD
  43. LOCAL iPerspStep:DWORD
  44. ')dnl
  45. ')dnl
  46. ifelse(eval(d_index($1, `NoZTest') < 0 && d_index($1, `NoColorKey') < 0), `1',
  47. ` LOCAL uZDef:WORD
  48. ')dnl
  49. ifelse(eval(d_index($1, `NoColorKey') < 0), `1',
  50. `ifelse(eval(d_index($1, `_8') >= 0), `1',
  51. ` LOCAL uTransPix:BYTE;
  52. ')dnl
  53. ifelse(eval(d_index($1, `_16') >= 0), `1',
  54. ` LOCAL uTransPix:WORD;
  55. ')dnl
  56. ')dnl
  57. LOCAL iShiftU:BYTE, iShiftV:BYTE
  58. PROF_ENTRY
  59. mov esi, pCtx
  60. ; Initialize texture rampmap.
  61. mov eax, [esi+RCTX_pTexture]
  62. cmp eax, 0
  63. je L_NoCtxTexture
  64. mov ecx, [esi+RCTX_pTexRampMap]
  65. mov [eax+STEX_pRampmap], ecx
  66. L_NoCtxTexture:
  67. ; Load initial prim.
  68. mov edi, [esi+RCTX_pPrim]
  69. L_Prims:
  70. cmp edi, 0
  71. je L_ReturnSuccess
  72. ; Get span count and start.
  73. mov eax, [edi+RASTPRIM_uSpans]
  74. lea ebx, [edi+SIZEOF_RASTPRIM]
  75. and eax, 0ffffh
  76. L_Spans:
  77. jnz L_Span
  78. ; Get next prim in list.
  79. mov edi, [edi+RASTPRIM_pNext]
  80. jmp L_Prims
  81. L_Span:
  82. mov pP, edi
  83. mov pS, ebx
  84. mov uSpans, eax
  85. ifelse(eval(d_index($1, `_Tex') >= 0), `1', `
  86. ifelse(eval(d_index($1, `NoPersp') < 0), `1',
  87. ` ; Start perspective correction.
  88. ; OoW, UoW, VoW and increments are kept on the stack
  89. ; through the life of the function.
  90. ; Compute per-PWL step UoW, VoW and OoW increments.
  91. mov eax, [edi+RASTPRIM_iDUoW1DX]
  92. mov ecx, [edi+RASTPRIM_iDVoW1DX]
  93. mov edx, [edi+RASTPRIM_iDOoWDX]
  94. shl eax, PWL_PERSP_STEP_SHIFT
  95. shl ecx, PWL_PERSP_STEP_SHIFT
  96. shl edx, PWL_PERSP_STEP_SHIFT
  97. mov iU1, eax
  98. mov iV1, ecx
  99. mov iU2, edx
  100. fild iU1 ; DUoW
  101. fild iV1 ; DVoW DUoW
  102. fild iU2 ; DOoW DVoW DUoW
  103. ; Compute initial U,V from given W.
  104. fild DWORD PTR [ebx+RASTSPAN_iW] ; W
  105. fmul TEX_UVW_TO_FINAL_SCALE ; W
  106. fild DWORD PTR [ebx+RASTSPAN_iUoW1] ; UoW W
  107. fild DWORD PTR [ebx+RASTSPAN_iVoW1] ; VoW UoW W
  108. fxch st(2) ; W UoW VoW
  109. fld st(0) ; W W UoW VoW
  110. fmul st(0), st(2) ; U W UoW VoW
  111. fild DWORD PTR [ebx+RASTSPAN_iOoW] ; OoW U W UoW VoW
  112. fxch st(2) ; W U OoW UoW VoW
  113. fmul st(0), st(4) ; V U OoW UoW VoW
  114. fxch st(1) ; U V OoW UoW VoW
  115. fistp iU2 ; V OoW UoW VoW
  116. ; Force initial pixel to do correction.
  117. mov eax, 1
  118. fistp iV2 ; OoW UoW VoW
  119. mov iPerspStep, eax
  120. ; Update OoW and start next W divide.
  121. fadd st(0), st(3) ; OoW UoW VoW DOoW DVoW DUoW
  122. fld TEX_OOW_TO_FINAL_SCALE ; 1 OoW UoW VoW DOoW DVoW DUoW
  123. fdiv st(0), st(1) ; W OoW UoW VoW DOoW DVoW DUoW
  124. ; Stack is W OoW UoW VoW DOoW DVoW DUoW.
  125. ')dnl
  126. ')dnl
  127. ;
  128. ; Get values into local variables.
  129. ;
  130. mov edx, [esi+RCTX_pTexture]
  131. mov eax, [edx+STEX_uMaskU]
  132. mov ecx, [edx+STEX_uMaskV]
  133. and eax, 0ffffh
  134. and ecx, 0ffffh
  135. mov uMaskU, eax
  136. mov uMaskV, ecx
  137. mov eax, TEX_FINAL_SHIFT
  138. mov ecx, eax
  139. sub eax, [edx+STEX_iShiftU]
  140. sub ecx, [edx+STEX_iShiftV]
  141. mov iShiftU, al
  142. mov iShiftV, cl
  143. mov eax, [edx+STEX_pBits]
  144. mov cl, [edx+STEX_iShiftPitch]
  145. mov pTexBits, eax
  146. mov iShiftPitch, cl
  147. ifelse(eval(d_index($1, `NoColorKey') < 0), `1',
  148. `ifelse(eval(d_index($1, `_8') >= 0), `1',
  149. ` mov al, [edx+STEX_TransparentColor]
  150. mov uTransPix, al
  151. ')dnl
  152. ifelse(eval(d_index($1, `_16') >= 0), `1',
  153. ` mov ax, [edx+STEX_TransparentColor]
  154. mov uTransPix, ax
  155. ')dnl
  156. ')dnl
  157. ifelse(eval(d_index($1, `NoZTest') < 0), `1',
  158. ` mov ecx, [ebx+RASTSPAN_uZ]
  159. mov edx, [edi+RASTPRIM_iDZDX]
  160. mov uZ, ecx
  161. mov iDZDX, edx
  162. ')dnl
  163. ; Determine buffer steps from span direction.
  164. mov eax, [edi+RASTPRIM_uFlags]
  165. test eax, D3DI_RASTPRIM_X_DEC
  166. mov eax, [esi+RCTX_iSurfaceStep]
  167. ifelse(eval(d_index($1, `NoZTest') < 0), `1',
  168. ` mov ecx, [esi+RCTX_iZStep]
  169. ')dnl
  170. jz L_XInc
  171. ; X_DEC
  172. neg eax
  173. ifelse(eval(d_index($1, `NoZTest') < 0), `1',
  174. ` neg ecx
  175. ')dnl
  176. L_XInc:
  177. mov iSurfStep, eax
  178. ifelse(eval(d_index($1, `NoZTest') < 0), `1',
  179. ` mov iZStep, ecx
  180. ')dnl
  181. ;
  182. ; Pixel loop.
  183. ;
  184. ; edi is the destination surface.
  185. mov edi, [ebx+RASTSPAN_pSurface]
  186. ifelse(eval(d_index($1, `NoZTest') < 0), `1',
  187. ` ; esi is the Z surface.
  188. mov esi, [ebx+RASTSPAN_pZ]
  189. ')dnl
  190. ; ebx is the pixel count.
  191. mov ebx, [ebx+RASTSPAN_uPix]
  192. and ebx, 0ffffh
  193. L_Pixels:
  194. ifelse(eval(d_index($1, `_Tex') >= 0), `1', `
  195. ifelse(eval(d_index($1, `NoPersp') < 0), `1',
  196. ` dec iPerspStep
  197. jnz L_PerspDone
  198. mov eax, iU2
  199. mov ecx, iV2
  200. mov iU1, eax
  201. mov iV1, ecx
  202. ; Stack is W OoW UoW VoW DOoW DVoW DUoW.
  203. ; Update UoW, VoW.
  204. fxch st(2) ; UoW OoW W VoW DOoW DVoW DUoW
  205. fadd st(0), st(6) ; UoW OoW W VoW DOoW DVoW DUoW
  206. fxch st(3) ; VoW OoW W UoW DOoW DVoW DUoW
  207. fadd st(0), st(5) ; VoW OoW W UoW DOoW DVoW DUoW
  208. ; Compute new U, V, OoW.
  209. fld st(2) ;W VoW OoW W UoW DOoW DVoW DUoW
  210. fmul st(0), st(4) ;U VoW OoW W UoW DOoW DVoW DUoW
  211. fxch st(2) ;OoW VoW U W UoW DOoW DVoW DUoW
  212. fadd st(0), st(5) ;OoW VoW U W UoW DOoW DVoW DUoW
  213. fxch st(3) ;W VoW U OoW UoW DOoW DVoW DUoW
  214. fmul st(0), st(1) ;V VoW U OoW UoW DOoW DVoW DUoW
  215. fxch st(2) ;U VoW V OoW UoW DOoW DVoW DUoW
  216. fistp iU2 ;VoW V OoW UoW DOoW DVoW DUoW
  217. fxch st(1) ;V VoW OoW UoW DOoW DVoW DUoW
  218. fistp iV2 ;VoW OoW UoW DOoW DVoW DUoW
  219. ; Reorder stack and start new W divide.
  220. fxch st(2) ; UoW OoW VoW DOoW DVoW DUoW
  221. fxch st(1) ; OoW UoW VoW DOoW DVoW DUoW
  222. fld TEX_OOW_TO_FINAL_SCALE ; 1 OoW UoW VoW DOoW DVoW DUoW
  223. fdiv st(0), st(1) ; W OoW UoW VoW DOoW DVoW DUoW
  224. ; Compute linear deltas.
  225. mov eax, iU2
  226. mov ecx, iV2
  227. sub eax, iU1
  228. sub ecx, iV1
  229. mov edx, PWL_PERSP_STEP
  230. shr eax, PWL_PERSP_STEP_SHIFT
  231. shr ecx, PWL_PERSP_STEP_SHIFT
  232. mov iDUDX, eax
  233. mov iDVDX, ecx
  234. mov iPerspStep, edx
  235. L_PerspDone:
  236. ')dnl
  237. ')dnl
  238. ifelse(eval(d_index($1, `NoZTest') < 0), `1',
  239. ` ; Z test and update.
  240. mov ecx, uZ
  241. mov ax, [esi]
  242. mov edx, ecx
  243. add ecx, iDZDX
  244. shr edx, 15
  245. mov uZ, ecx
  246. cmp dx, ax
  247. ja L_NoPixel
  248. ifelse(eval(d_index($1, `NoColorKey') >= 0), `1',
  249. ` ; Theres no color key so we can write the Z immediately.
  250. mov [esi], dx
  251. ',
  252. ` ; Save Z for deferred write.
  253. mov uZDef, dx
  254. ')dnl
  255. ')dnl
  256. ifelse(eval(d_index($1, `_Tex') >= 0), `1', `
  257. ; Look up texel and keep in edx.
  258. mov edx, iU1
  259. mov cl, iShiftU
  260. mov eax, iV1
  261. shr edx, cl
  262. and edx, uMaskU
  263. mov cl, iShiftV
  264. add edx, pTexBits
  265. shr eax, cl
  266. and eax, uMaskV
  267. mov cl, iShiftPitch
  268. shl eax, cl
  269. add eax, edx
  270. ifelse(eval(d_index($1, `_8') >= 0), `1',
  271. ` mov dl, [eax]
  272. ')dnl
  273. ifelse(eval(d_index($1, `_16') >= 0), `1',
  274. ` mov dx, [eax]
  275. ')dnl
  276. ifelse(eval(d_index($1, `NoColorKey') < 0), `1',
  277. ` ; Color keying.
  278. ifelse(eval(d_index($1, `_8') >= 0), `1',
  279. ` cmp dl, uTransPix
  280. ')dnl
  281. ifelse(eval(d_index($1, `_16') >= 0), `1',
  282. ` cmp dx, uTransPix
  283. ')dnl
  284. je L_NoPixel
  285. ')dnl
  286. ', `
  287. mov dx, 1
  288. ')dnl
  289. ifelse(eval(d_index($1, `NoZTest') < 0 && d_index($1, `NoColorKey') < 0), `1',
  290. ` ; Do deferred Z write.
  291. mov ax, uZDef
  292. mov [esi], ax
  293. ')dnl
  294. ifelse(eval(d_index($1, `_8') >= 0), `1',
  295. ` mov [edi], dl
  296. ')dnl
  297. ifelse(eval(d_index($1, `_16') >= 0), `1',
  298. ` mov [edi], dx
  299. ')dnl
  300. ifelse(eval(d_index($1, `NoZTest') < 0 || d_index($1, `NoColorKey') < 0), `1',
  301. `L_NoPixel:
  302. ')dnl
  303. dec ebx
  304. jz L_Exit
  305. ; Update incremental values.
  306. ifelse(eval(d_index($1, `_Tex') >= 0), `1', `
  307. ifelse(eval(d_index($1, `NoPersp') < 0), `1',
  308. ` mov eax, iU1
  309. mov ecx, iV1
  310. add eax, iDUDX
  311. add ecx, iDVDX
  312. mov iU1, eax
  313. mov iV1, ecx
  314. ')dnl
  315. ')dnl
  316. add edi, iSurfStep
  317. ifelse(eval(d_index($1, `NoZTest') < 0), `1',
  318. ` add esi, iZStep
  319. ')dnl
  320. jmp L_Pixels
  321. L_Exit:
  322. ifelse(eval(d_index($1, `_Tex') >= 0), `1', `
  323. ifelse(eval(d_index($1, `NoPersp') < 0), `1',
  324. ` ; Clear FP stack.
  325. fstp st(0)
  326. fstp st(0)
  327. fstp st(0)
  328. fstp st(0)
  329. fstp st(0)
  330. fstp st(0)
  331. fstp st(0)
  332. ')dnl
  333. ')dnl
  334. ; Reload context and prim.
  335. mov esi, pCtx
  336. mov edi, pP
  337. ; Increment span pointer.
  338. mov ebx, pS
  339. mov eax, uSpans
  340. add ebx, SIZEOF_RASTSPAN
  341. dec eax
  342. jmp L_Spans
  343. L_ReturnSuccess:
  344. ; Return S_OK.
  345. xor eax, eax
  346. ret
  347. Ramp_$1 ENDP
  348. ')dnl
  349. ')dnl
  350. d_SpecializedRampRenderSpansBeads(`d_Ramp_Copy_Spans(XX)', `XX')dnl
  351. END