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.

280 lines
7.2 KiB

  1. ;-----------------------------------------------------------------------------
  2. ;
  3. ; This file contains x86 assembly edge walkers.
  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. include(`attrsx86.mh')dnl
  16. .386p
  17. .MODEL FLAT
  18. INCLUDE offs_acp.inc
  19. INCLUDE profile.inc
  20. ALLOC_SPANS EQU ?AllocSpans@PrimProcessor@@QAEJPAIPAPAUtagD3DI_RASTSPAN@@@Z
  21. FREE_SPANS EQU ?FreeSpans@PrimProcessor@@QAEXI@Z
  22. EXTERN ALLOC_SPANS:NEAR
  23. EXTERN FREE_SPANS:NEAR
  24. .CODE
  25. dnl
  26. dnl d_WalkTrapSpans
  27. dnl
  28. dnl Generates a complete monolithic trapezoid edge walker.
  29. dnl
  30. dnl $1 is one of Z_Diff, Z_Diff_Spec, Z_Diff_Tex1, Z_Diff_Spec_Tex1,
  31. dnl Z_Tex1_Tex2, Z_DIdx, Z_DIdx_Tex1, Z_Tex1.
  32. dnl $2 is one of Float Fixed.
  33. dnl
  34. define(`d_WalkTrapSpans', `
  35. ifelse($2, `Fixed',
  36. `IFDEF STEP_FIXED
  37. ')dnl
  38. @WalkTrap$2Spans_$1_NoClip@16 PROC SYSCALL PUBLIC USES ebx esi edi,
  39. pStpCtx:DWORD, bAdvanceLast:DWORD
  40. LOCAL uSpansAvail:DWORD, cPix:DWORD
  41. LOCAL pSpan:DWORD, pXOther:DWORD
  42. LOCAL pXLeft:DWORD, pXRight:DWORD
  43. ifelse(eval((d_index(`$1', `Diff') >= 0 || d_index(`$1', `Spec') >= 0) &&
  44. d_index(`$2', `Float') == 0), `1',
  45. ` LOCAL iVal:DWORD
  46. ')dnl
  47. PROF_ENTRY
  48. ; Initialize values:
  49. ; ebx will always contain the SETUPCTX.
  50. ; edi will always contain the number of available spans.
  51. ;
  52. ; esi will always contain the number of spans to go processed
  53. ; with bAdvance spans so that bAdvanceLast doesnt need to
  54. ; be checked. The span count is doubled and !bAdvanceLast
  55. ; is subtracted from it so esi = uSpans * 2 - !bAdvanceLast
  56. ; (bAdvanceLast is assumed to be one or zero).
  57. ; Both exit checks decrement esi so if bAdvanceLast is FALSE
  58. ; the first exit check will hit zero since one was subtracted.
  59. ; Otherwise the second one will hit zero.
  60. mov ebx, pStpCtx
  61. mov esi, ecx
  62. shl esi, 1
  63. mov eax, bAdvanceLast
  64. mov ecx, [ebx+SCTX_uFlags]
  65. xor edi, edi
  66. xor eax, 1
  67. sub esi, eax
  68. test ecx, TRIF_X_DEC
  69. mov pXOther, edx
  70. ; Clear PWL flags.
  71. mov [ebx+SCTX_uPwlFlags], edi
  72. jnz L_XDec
  73. ; X increments.
  74. lea eax, [ebx+SCTX_X20]
  75. jmp L_StoreEdges
  76. L_XDec:
  77. mov eax, edx
  78. lea edx, [ebx+SCTX_X20]
  79. L_StoreEdges:
  80. mov pXLeft, eax
  81. mov pXRight, edx
  82. jmp L_SpanLoopEdges
  83. L_SpanLoop:
  84. mov eax, pXLeft
  85. mov edx, pXRight
  86. L_SpanLoopEdges:
  87. ; If the right edge is less than or equal to the left edge
  88. ; there are no pixels to draw.
  89. mov eax, [eax+ICV_iV]
  90. mov edx, [edx+ICV_iV]
  91. sub edx, eax
  92. jle L_NoPixels
  93. ; Check for available spans.
  94. test edi, edi
  95. mov cPix, edx
  96. jz L_NoSpansAvail
  97. ; Increment span pointer.
  98. mov edx, pSpan
  99. add edx, SIZEOF_RASTSPAN
  100. mov pSpan, edx
  101. jmp L_ConsumeSpan
  102. L_NoSpansAvail:
  103. ; Try to alloc the remaining number of spans.
  104. mov ecx, esi
  105. inc ecx
  106. lea eax, pSpan
  107. shr ecx, 1
  108. mov uSpansAvail, ecx
  109. push eax
  110. lea edx, uSpansAvail
  111. push edx
  112. mov ecx, [ebx+SCTX_PrimProcessor]
  113. call ALLOC_SPANS
  114. test eax, eax
  115. jnz L_Exit
  116. ; Reload count of available spans and load span pointer into edx.
  117. mov edi, uSpansAvail
  118. mov edx, pSpan
  119. L_ConsumeSpan:
  120. ; Decrement count of available spans and increment
  121. ; RASTPRIM span count.
  122. mov ecx, [ebx+SCTX_pPrim]
  123. dec edi
  124. mov eax, [ecx+RASTPRIM_uSpans]
  125. ; Assumes uSpans will never overflow 16 bits.
  126. inc eax
  127. mov [ecx+RASTPRIM_uSpans], eax
  128. ; Set uPix for span. Relies on being able to set 32 bits
  129. ; even though uPix is a UINT16.
  130. mov eax, cPix
  131. mov [edx+RASTSPAN_uPix], eax
  132. ; Set uX and uY for span.
  133. ; Relies on uX and uY both being UINT16 in that order and
  134. ; that both require no masking.
  135. mov eax, [ebx+SCTX_X20+ICV_iV]
  136. mov ecx, [ebx+SCTX_iY]
  137. shl ecx, 16
  138. or eax, ecx
  139. mov [edx+RASTSPAN_uX], eax
  140. lea ecx, [ebx+SCTX_Attr]
  141. ; Fill RASTSPAN attributes. edx is already set to the span.
  142. d_FillSpan$2AttrsBody(`$1')dnl
  143. L_NoPixels:
  144. ; Decrement the span count and check for exit.
  145. dec esi
  146. jz L_Success
  147. ;
  148. ; Advance long edge and all attributes.
  149. ;
  150. ; Increment iY and add X20 fraction.
  151. mov eax, [ebx+SCTX_iY]
  152. mov ecx, [ebx+SCTX_X20+ICV_iFrac]
  153. inc eax
  154. add ecx, [ebx+SCTX_X20+ICV_iDFrac]
  155. mov [ebx+SCTX_iY], eax
  156. js L_X20Carry
  157. ; No-carry step. Put DAttrNC in edx.
  158. mov [ebx+SCTX_X20+ICV_iFrac], ecx
  159. mov eax, [ebx+SCTX_X20+ICV_iV]
  160. lea edx, [ebx+SCTX_DAttrNC]
  161. mov ecx, [ebx+SCTX_X20+ICV_iNC]
  162. jmp L_AddAttrs
  163. L_X20Carry:
  164. ; Carry step. Put DAttrCY in edx.
  165. and ecx, 07fffffffh
  166. mov eax, [ebx+SCTX_X20+ICV_iV]
  167. lea edx, [ebx+SCTX_DAttrCY]
  168. mov [ebx+SCTX_X20+ICV_iFrac], ecx
  169. mov ecx, [ebx+SCTX_X20+ICV_iCY]
  170. L_AddAttrs:
  171. ; Store results and add attributes. pDelta is already in edx.
  172. add eax, ecx
  173. lea ecx, [ebx+SCTX_Attr]
  174. mov [ebx+SCTX_X20+ICV_iV], eax
  175. d_Add$2AttrsBody(`$1')dnl
  176. ; Long edge updating is done so check for exit again.
  177. dec esi
  178. jz L_Success
  179. ; Update short edge.
  180. mov edx, pXOther
  181. mov eax, [edx+ICV_iFrac]
  182. mov ecx, [edx+ICV_iV]
  183. add eax, [edx+ICV_iDFrac]
  184. js L_XOtherCarry
  185. ; No-carry step.
  186. add ecx, [edx+ICV_iNC]
  187. mov [edx+ICV_iFrac], eax
  188. mov [edx+ICV_iV], ecx
  189. jmp L_SpanLoop
  190. L_XOtherCarry:
  191. ; Carry step.
  192. and eax, 07fffffffh
  193. add ecx, [edx+ICV_iCY]
  194. mov [edx+ICV_iFrac], eax
  195. mov [edx+ICV_iV], ecx
  196. jmp L_SpanLoop
  197. L_Success:
  198. ; Set D3D_OK
  199. xor eax, eax
  200. L_Exit:
  201. test edi, edi
  202. ; Temporarily keep return code in esi.
  203. mov esi, eax
  204. jz L_NoUnusedSpans
  205. mov ecx, [ebx+SCTX_PrimProcessor]
  206. push edi
  207. call FREE_SPANS
  208. L_NoUnusedSpans:
  209. mov eax, esi
  210. ret 8
  211. @WalkTrap$2Spans_$1_NoClip@16 ENDP
  212. ifelse($2, `Fixed',
  213. `ENDIF
  214. ')dnl
  215. ')dnl
  216. dnl
  217. d_RepStr(`d_RepStr(`d_WalkTrapSpans(AA, BB)',
  218. `AA', `Z_Diff', `Z_Diff_Spec', `Z_Diff_Tex1', `Z_Diff_Spec_Tex1',
  219. `Z_Tex1_Tex2', `Z_DIdx', `Z_DIdx_Tex1', `Z_Tex1')',
  220. `BB', `Float', `Fixed')dnl
  221. END