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.

629 lines
19 KiB

  1. ;-----------------------------------------------------------------------------
  2. ;
  3. ; This file contains the source and destination alpha blend functions.
  4. ;
  5. ; Currently Im assuming that uBB, uBG, uBR, uBA are in mm1,
  6. ; DestC is in mm3 in the lower 8 bits of each word
  7. ; and that the result will be in mm1.
  8. ;
  9. ; mm3 is preserved in Src Blend Functions since Dest Blend
  10. ; function call will be right afterwards
  11. ;
  12. ; mm2 is used as a temporary in these routines. All other
  13. ; registers are okay to use.
  14. ;
  15. ; Called by ColorBld in BlendAll cases.
  16. ;
  17. ; Optimization Note: All routines shift mm1 down by 8, which I could
  18. ; do before I call the routines and it could eliminate
  19. ; one shift since I would only do it once instead of in
  20. ; both the src and dest blend cases. Only one cycle savings though.
  21. ;
  22. ;-----------------------------------------------------------------------------
  23. .586
  24. .model flat
  25. .data
  26. PUBLIC Val0x0000ffffffffffff
  27. Val0x0000ffffffffffff dq 0000ffffffffffffh
  28. PUBLIC Val0x0100000000000000
  29. Val0x0100000000000000 dq 0100000000000000h
  30. .code
  31. INCLUDE iammx.inc
  32. INCLUDE offs_acp.inc
  33. ;-----------------------------------------------------------------------------
  34. ;
  35. ; SrcBlendZero
  36. ;
  37. ; (0, 0, 0, 0) * Src
  38. ;
  39. ;-----------------------------------------------------------------------------
  40. ;void SrcBlendZero(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  41. ;{
  42. PUBLIC _MMX_SrcBlend_Zero
  43. _MMX_SrcBlend_Zero:
  44. ;*pR = 0;
  45. ;*pG = 0;
  46. ;*pB = 0;
  47. ;*pA = 0;
  48. pxor mm1, mm1
  49. ret
  50. ;}
  51. ;-----------------------------------------------------------------------------
  52. ;
  53. ; SrcBlendOne
  54. ;
  55. ; (1, 1, 1, 1) * Src
  56. ;
  57. ;-----------------------------------------------------------------------------
  58. ;void SrcBlendOne(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  59. ;{
  60. PUBLIC _MMX_SrcBlend_One
  61. _MMX_SrcBlend_One:
  62. ;*pR = pCtx->SI.uBR;
  63. ;*pG = pCtx->SI.uBG;
  64. ;*pB = pCtx->SI.uBB;
  65. ;*pA = pCtx->SI.uBA;
  66. ret
  67. ;}
  68. ;-----------------------------------------------------------------------------
  69. ;
  70. ; SrcBlendSrcColor
  71. ;
  72. ; (Rs, Gs, Bs, As) * Src
  73. ;
  74. ;-----------------------------------------------------------------------------
  75. ;void SrcBlendSrcColor(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  76. ;{
  77. PUBLIC _MMX_SrcBlend_SrcColor
  78. _MMX_SrcBlend_SrcColor:
  79. ;*pR = (pCtx->SI.uBR>>8)*(pCtx->SI.uBR>>8);
  80. ;*pG = (pCtx->SI.uBG>>8)*(pCtx->SI.uBG>>8);
  81. ;*pB = (pCtx->SI.uBB>>8)*(pCtx->SI.uBB>>8);
  82. ;*pA = (pCtx->SI.uBA>>8)*(pCtx->SI.uBA>>8);
  83. psrlw mm1, 8
  84. pmullw mm1, mm1
  85. ret
  86. ;}
  87. ;-----------------------------------------------------------------------------
  88. ;
  89. ; SrcBlendInvSrcColor
  90. ;
  91. ; (1-Rs, 1-Gs, 1-Bs, 1-As) * Src
  92. ;
  93. ;-----------------------------------------------------------------------------
  94. ;void SrcBlendInvSrcColor(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  95. ;{
  96. PUBLIC _MMX_SrcBlend_InvSrcColor
  97. _MMX_SrcBlend_InvSrcColor:
  98. ;*pR = (0xff - (pCtx->SI.uBR>>8))*(pCtx->SI.uBR>>8);
  99. ;*pG = (0xff - (pCtx->SI.uBG>>8))*(pCtx->SI.uBG>>8);
  100. ;*pB = (0xff - (pCtx->SI.uBB>>8))*(pCtx->SI.uBB>>8);
  101. ;*pA = (0xff - (pCtx->SI.uBA>>8))*(pCtx->SI.uBA>>8);
  102. pcmpeqw mm2, mm2 ; generate one
  103. psrlw mm2, 8
  104. psrlw mm1, 8
  105. psubw mm2, mm1 ; generate 1-color
  106. pmullw mm1, mm2 ; multiply by color
  107. ret
  108. ;}
  109. ;-----------------------------------------------------------------------------
  110. ;
  111. ; SrcBlendSrcAlpha
  112. ;
  113. ; (As, As, As, As) * Src
  114. ;
  115. ;-----------------------------------------------------------------------------
  116. ;void SrcBlendSrcAlpha(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  117. ;{
  118. PUBLIC _MMX_SrcBlend_SrcAlpha
  119. _MMX_SrcBlend_SrcAlpha:
  120. ;UINT16 f = pCtx->SI.uBA>>8;
  121. psrlw mm1, 8
  122. movq mm2, mm1 ; Save color for a bit.
  123. ;TBD Make sure replication process is in correct order.
  124. punpckhwd mm1, mm1 ; Replicate alpha
  125. punpckhdq mm1, mm1 ; Replicate alpha again
  126. ;*pR = f*(pCtx->SI.uBR>>8);
  127. ;*pG = f*(pCtx->SI.uBG>>8);
  128. ;*pB = f*(pCtx->SI.uBB>>8);
  129. ;*pA = f*(pCtx->SI.uBA>>8);
  130. pmullw mm1, mm2
  131. ret
  132. ;}
  133. ;-----------------------------------------------------------------------------
  134. ;
  135. ; SrcBlendInvSrcAlpha
  136. ;
  137. ; (1-As, 1-As, 1-As, 1-As) * Src
  138. ;
  139. ;-----------------------------------------------------------------------------
  140. ;void SrcBlendInvSrcAlpha(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  141. ;{
  142. PUBLIC _MMX_SrcBlend_InvSrcAlpha
  143. _MMX_SrcBlend_InvSrcAlpha:
  144. ;UINT16 f = 0xff - (pCtx->SI.uBA>>8);
  145. psrlw mm1, 8
  146. pcmpeqw mm2, mm2 ; generate one
  147. psrlw mm2, 8
  148. psubw mm2, mm1 ; generate 1-alpha
  149. ;TBD Make sure replication process is in correct order.
  150. punpckhwd mm2, mm2 ; Replicate 1-alpha
  151. punpckhdq mm2, mm2 ; Replicate 1-alpha again
  152. ;*pR = f*(pCtx->SI.uBR>>8);
  153. ;*pG = f*(pCtx->SI.uBG>>8);
  154. ;*pB = f*(pCtx->SI.uBB>>8);
  155. ;*pA = f*(pCtx->SI.uBA>>8);
  156. pmullw mm1, mm2
  157. ret
  158. ;}
  159. ;-----------------------------------------------------------------------------
  160. ;
  161. ; SrcBlendDestAlpha
  162. ;
  163. ; (Ad, Ad, Ad, Ad) * Src
  164. ;
  165. ;-----------------------------------------------------------------------------
  166. ;void SrcBlendDestAlpha(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  167. ;{
  168. PUBLIC _MMX_SrcBlend_DestAlpha
  169. _MMX_SrcBlend_DestAlpha:
  170. ;UINT16 f = (UINT16)RGBA_GETALPHA(DestC);
  171. ;TBD Make sure replication process is in correct order.
  172. psrlw mm1, 8
  173. movq mm2, mm3 ; Dont destory mm3 in Src routines. Okay to
  174. ; destory in Dest routines.
  175. punpckhwd mm2, mm2 ; Replicate alpha
  176. punpckhdq mm2, mm2 ; Replicate alpha again
  177. ;*pR = f*(pCtx->SI.uBR>>8);
  178. ;*pG = f*(pCtx->SI.uBG>>8);
  179. ;*pB = f*(pCtx->SI.uBB>>8);
  180. ;*pA = f*(pCtx->SI.uBA>>8);
  181. pmullw mm1, mm2
  182. ret
  183. ;}
  184. ;-----------------------------------------------------------------------------
  185. ;
  186. ; SrcBlendInvDestAlpha
  187. ;
  188. ; (1-Ad, 1-Ad, 1-Ad, 1-Ad) * Src
  189. ;
  190. ;-----------------------------------------------------------------------------
  191. ;void SrcBlendInvDestAlpha(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  192. ;{
  193. PUBLIC _MMX_SrcBlend_InvDestAlpha
  194. _MMX_SrcBlend_InvDestAlpha:
  195. ;UINT16 f = 0xff - (UINT16)RGBA_GETALPHA(DestC);
  196. psrlw mm1, 8
  197. pcmpeqw mm2, mm2 ; generate one
  198. psrlw mm2, 8
  199. psubw mm2, mm3 ; generate 1-alpha
  200. ;TBD Make sure replication process is in correct order.
  201. punpckhwd mm2, mm2 ; Replicate 1-alpha
  202. punpckhdq mm2, mm2 ; Replicate 1-alpha again
  203. ;*pR = f*(pCtx->SI.uBR>>8);
  204. ;*pG = f*(pCtx->SI.uBG>>8);
  205. ;*pB = f*(pCtx->SI.uBB>>8);
  206. ;*pA = f*(pCtx->SI.uBA>>8);
  207. pmullw mm1, mm2
  208. ret
  209. ;}
  210. ;-----------------------------------------------------------------------------
  211. ;
  212. ; SrcBlendDestColor
  213. ;
  214. ; (Rd, Gd, Bd, Ad) * Src
  215. ;
  216. ;-----------------------------------------------------------------------------
  217. ;void SrcBlendDestColor(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  218. ;{
  219. PUBLIC _MMX_SrcBlend_DestColor
  220. _MMX_SrcBlend_DestColor:
  221. ;*pR = (UINT16)RGBA_GETRED(DestC) *(pCtx->SI.uBR>>8);
  222. ;*pG = (UINT16)RGBA_GETGREEN(DestC)*(pCtx->SI.uBG>>8);
  223. ;*pB = (UINT16)RGBA_GETBLUE(DestC) *(pCtx->SI.uBB>>8);
  224. ;*pA = (UINT16)RGBA_GETALPHA(DestC)*(pCtx->SI.uBA>>8);
  225. psrlw mm1, 8
  226. pmullw mm1, mm3
  227. ret
  228. ;}
  229. ;-----------------------------------------------------------------------------
  230. ;
  231. ; SrcBlendInvDestColor
  232. ;
  233. ; (1-Rd, 1-Gd, 1-Bd, 1-Ad) * Src
  234. ;
  235. ;-----------------------------------------------------------------------------
  236. ;void SrcBlendInvDestColor(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  237. ;{
  238. PUBLIC _MMX_SrcBlend_InvDestColor
  239. _MMX_SrcBlend_InvDestColor:
  240. ;*pR = (0xff - (UINT16)RGBA_GETRED(DestC) )*(pCtx->SI.uBR>>8);
  241. ;*pG = (0xff - (UINT16)RGBA_GETGREEN(DestC))*(pCtx->SI.uBG>>8);
  242. ;*pB = (0xff - (UINT16)RGBA_GETBLUE(DestC) )*(pCtx->SI.uBB>>8);
  243. ;*pA = (0xff - (UINT16)RGBA_GETALPHA(DestC))*(pCtx->SI.uBA>>8);
  244. ;UINT16 f = 0xff - (UINT16)RGBA_GETALPHA(DestC);
  245. psrlw mm1, 8
  246. pcmpeqw mm2, mm2 ; generate one
  247. psrlw mm2, 8
  248. psubw mm2, mm3 ; generate 1-destC
  249. pmullw mm1, mm2
  250. ret
  251. ;}
  252. ;-----------------------------------------------------------------------------
  253. ;
  254. ; SrcBlendSrcAlphaSat
  255. ;
  256. ; f = min(as, 1-Ad); (f, f, f, 1) * Src
  257. ;
  258. ;-----------------------------------------------------------------------------
  259. ;void SrcBlendSrcAlphaSat(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  260. ;{
  261. PUBLIC _MMX_SrcBlend_SrcAlphaSat
  262. _MMX_SrcBlend_SrcAlphaSat:
  263. ; TBD do code fore this.
  264. ;UINT16 f = min(pCtx->SI.uBA>>8, 0xff - (UINT16)RGBA_GETALPHA(DestC));
  265. psrlw mm1, 8
  266. pcmpeqw mm2, mm2
  267. psrlw mm2, 8
  268. psubw mm2, mm3
  269. movq mm7, mm1 ; Cant destory mm3 or could use it here,
  270. ; This does min. Only interested in alpha in this anyway.
  271. pcmpgtw mm7, mm2 ; mask true if DestCA < uBA
  272. pand mm2, mm7 ;
  273. pandn mm7, mm1 ;
  274. por mm2, mm7
  275. punpckhwd mm2, mm2 ; Replicate alpha
  276. punpckhdq mm2, mm2 ; Replicate alpha again
  277. ; Make alpha value b
  278. pand mm2, MMWORD PTR Val0x0000ffffffffffff
  279. por mm2, MMWORD PTR Val0x0100000000000000
  280. ;*pR = f*(pCtx->SI.uBR>>8);
  281. ;*pG = f*(pCtx->SI.uBG>>8);
  282. ;*pB = f*(pCtx->SI.uBB>>8);
  283. ;*pA = pCtx->SI.uBA;
  284. pmullw mm1, mm2
  285. ret
  286. ;}
  287. ;-----------------------------------------------------------------------------
  288. ;
  289. ; DestBlendZero
  290. ;
  291. ; (0, 0, 0, 0) * Dest
  292. ;
  293. ;-----------------------------------------------------------------------------
  294. ;void DestBlendZero(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  295. ;{
  296. PUBLIC _MMX_DestBlend_Zero
  297. _MMX_DestBlend_Zero:
  298. ;*pR = 0;
  299. ;*pG = 0;
  300. ;*pB = 0;
  301. ;*pA = 0;
  302. pxor mm1, mm1
  303. ret
  304. ;}
  305. ;-----------------------------------------------------------------------------
  306. ;
  307. ; DestBlendOne
  308. ;
  309. ; (1, 1, 1, 1) * Dest
  310. ;
  311. ;-----------------------------------------------------------------------------
  312. ;void DestBlendOne(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  313. ;{
  314. PUBLIC _MMX_DestBlend_One
  315. _MMX_DestBlend_One:
  316. ;*pR = ((UINT16)RGBA_GETRED(DestC) <<8);
  317. ;*pG = ((UINT16)RGBA_GETGREEN(DestC)<<8);
  318. ;*pB = ((UINT16)RGBA_GETBLUE(DestC) <<8);
  319. ;*pA = ((UINT16)RGBA_GETALPHA(DestC)<<8);
  320. movq mm1, mm3
  321. psllw mm1, 8
  322. ret
  323. ;}
  324. ;-----------------------------------------------------------------------------
  325. ;
  326. ; DestBlendSrcColor
  327. ;
  328. ; (Rs, Gs, Bs, As) * Dest
  329. ;
  330. ;-----------------------------------------------------------------------------
  331. ;void DestBlendSrcColor(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  332. ;{
  333. PUBLIC _MMX_DestBlend_SrcColor
  334. _MMX_DestBlend_SrcColor:
  335. ;*pR = (pCtx->SI.uBR>>8)*((UINT16)RGBA_GETRED(DestC) );
  336. ;*pG = (pCtx->SI.uBG>>8)*((UINT16)RGBA_GETGREEN(DestC));
  337. ;*pB = (pCtx->SI.uBB>>8)*((UINT16)RGBA_GETBLUE(DestC) );
  338. ;*pA = (pCtx->SI.uBA>>8)*((UINT16)RGBA_GETALPHA(DestC));
  339. psrlw mm1, 8
  340. pmullw mm1, mm3
  341. ret
  342. ;}
  343. ;-----------------------------------------------------------------------------
  344. ;
  345. ; DestBlendInvSrcColor
  346. ;
  347. ; (1-Rs, 1-Gs, 1-Bs, 1-As) * Dest
  348. ;
  349. ;-----------------------------------------------------------------------------
  350. ;void DestBlendInvSrcColor(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  351. ;{
  352. PUBLIC _MMX_DestBlend_InvSrcColor
  353. _MMX_DestBlend_InvSrcColor:
  354. ;*pR = (0xff - (pCtx->SI.uBR>>8))*((UINT16)RGBA_GETRED(DestC) );
  355. ;*pG = (0xff - (pCtx->SI.uBG>>8))*((UINT16)RGBA_GETGREEN(DestC));
  356. ;*pB = (0xff - (pCtx->SI.uBB>>8))*((UINT16)RGBA_GETBLUE(DestC) );
  357. ;*pA = (0xff - (pCtx->SI.uBA>>8))*((UINT16)RGBA_GETALPHA(DestC));
  358. psrlw mm1, 8
  359. pcmpeqw mm2, mm2
  360. psrlw mm2, 8
  361. psubw mm2, mm1
  362. pmullw mm2, mm3
  363. movq mm1, mm2
  364. ret
  365. ;}
  366. ;-----------------------------------------------------------------------------
  367. ;
  368. ; DestBlendSrcAlpha
  369. ;
  370. ; (As, As, As, As) * Dest
  371. ;
  372. ;-----------------------------------------------------------------------------
  373. ;void DestBlendSrcAlpha(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  374. ;{
  375. PUBLIC _MMX_DestBlend_SrcAlpha
  376. _MMX_DestBlend_SrcAlpha:
  377. ;UINT16 f = pCtx->SI.uBA>>8;
  378. psrlw mm1, 8
  379. punpckhwd mm1, mm1 ; Replicate alpha
  380. punpckhdq mm1, mm1 ; Replicate alpha again
  381. ;*pR = f*((UINT16)RGBA_GETRED(DestC) );
  382. ;*pG = f*((UINT16)RGBA_GETGREEN(DestC));
  383. ;*pB = f*((UINT16)RGBA_GETBLUE(DestC) );
  384. ;*pA = f*((UINT16)RGBA_GETALPHA(DestC));
  385. pmullw mm1, mm3
  386. ret
  387. ;}
  388. ;-----------------------------------------------------------------------------
  389. ;
  390. ; DestBlendInvSrcAlpha
  391. ;
  392. ; (1-As, 1-As, 1-As, 1-As) * Dest
  393. ;
  394. ;-----------------------------------------------------------------------------
  395. ;void DestBlendInvSrcAlpha(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  396. ;{
  397. PUBLIC _MMX_DestBlend_InvSrcAlpha
  398. _MMX_DestBlend_InvSrcAlpha:
  399. ; Register could be done differently here.
  400. ;UINT16 f = 0xff - (pCtx->SI.uBA>>8);
  401. psrlw mm1, 8
  402. pcmpeqw mm2, mm2
  403. psrlw mm2, 8
  404. psubw mm2, mm1
  405. punpckhwd mm2, mm2 ; Replicate alpha
  406. punpckhdq mm2, mm2 ; Replicate alpha again
  407. ;*pR = f*((UINT16)RGBA_GETRED(DestC) );
  408. ;*pG = f*((UINT16)RGBA_GETGREEN(DestC));
  409. ;*pB = f*((UINT16)RGBA_GETBLUE(DestC) );
  410. ;*pA = f*((UINT16)RGBA_GETALPHA(DestC));
  411. pmullw mm2, mm3
  412. movq mm1, mm2
  413. ret
  414. ;}
  415. ;-----------------------------------------------------------------------------
  416. ;
  417. ; DestBlendDestAlpha
  418. ;
  419. ; (Ad, Ad, Ad, Ad) * Dest
  420. ;
  421. ;-----------------------------------------------------------------------------
  422. ;void DestBlendDestAlpha(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  423. ;{
  424. PUBLIC _MMX_DestBlend_DestAlpha
  425. _MMX_DestBlend_DestAlpha:
  426. ;UINT16 f = (UINT16)RGBA_GETALPHA(DestC);
  427. movq mm1, mm3 ; Save color for a bit.
  428. ;TBD Make sure replication process is in correct order.
  429. punpckhwd mm3, mm3 ; Replicate alpha
  430. punpckhdq mm3, mm3 ; Replicate alpha again
  431. ;*pR = f*((UINT16)RGBA_GETRED(DestC) );
  432. ;*pG = f*((UINT16)RGBA_GETGREEN(DestC));
  433. ;*pB = f*((UINT16)RGBA_GETBLUE(DestC) );
  434. ;*pA = f*((UINT16)RGBA_GETALPHA(DestC));
  435. pmullw mm1, mm3
  436. ret
  437. ;}
  438. ;-----------------------------------------------------------------------------
  439. ;
  440. ; DestBlendInvDestAlpha
  441. ;
  442. ; (1-Ad, 1-Ad, 1-Ad, 1-Ad) * Dest
  443. ;
  444. ;-----------------------------------------------------------------------------
  445. ;void DestBlendInvDestAlpha(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  446. ;{
  447. PUBLIC _MMX_DestBlend_InvDestAlpha
  448. _MMX_DestBlend_InvDestAlpha:
  449. ;UINT16 f = 0xff - (UINT16)RGBA_GETALPHA(DestC);
  450. movq mm1, mm3 ; Save color for a bit.
  451. pcmpeqw mm2, mm2
  452. psrlw mm2, 8
  453. psubw mm2, mm3
  454. ;TBD Make sure replication process is in correct order.
  455. punpckhwd mm2, mm2 ; Replicate alpha
  456. punpckhdq mm2, mm2 ; Replicate alpha again
  457. ;*pR = f*((UINT16)RGBA_GETRED(DestC) );
  458. ;*pG = f*((UINT16)RGBA_GETGREEN(DestC));
  459. ;*pB = f*((UINT16)RGBA_GETBLUE(DestC) );
  460. ;*pA = f*((UINT16)RGBA_GETALPHA(DestC));
  461. pmullw mm1, mm2
  462. ret
  463. ;}
  464. ;-----------------------------------------------------------------------------
  465. ;
  466. ; DestBlendDestColor
  467. ;
  468. ; (Rd, Gd, Bd, Ad) * Dest
  469. ;
  470. ;-----------------------------------------------------------------------------
  471. ;void DestBlendDestColor(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  472. ;{
  473. PUBLIC _MMX_DestBlend_DestColor
  474. _MMX_DestBlend_DestColor:
  475. ;*pR = ((UINT16)RGBA_GETRED(DestC) )*((UINT16)RGBA_GETRED(DestC) );
  476. ;*pG = ((UINT16)RGBA_GETGREEN(DestC))*((UINT16)RGBA_GETGREEN(DestC));
  477. ;*pB = ((UINT16)RGBA_GETBLUE(DestC) )*((UINT16)RGBA_GETBLUE(DestC) );
  478. ;*pA = ((UINT16)RGBA_GETALPHA(DestC))*((UINT16)RGBA_GETALPHA(DestC));
  479. movq mm1, mm3
  480. pmullw mm1, mm1
  481. ret
  482. ;}
  483. ;-----------------------------------------------------------------------------
  484. ;
  485. ; DestBlendInvDestColor
  486. ;
  487. ; (1-Rd, 1-Gd, 1-Bd, 1-Ad) * Dest
  488. ;
  489. ;-----------------------------------------------------------------------------
  490. ;void DestBlendInvDestColor(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  491. ;{
  492. PUBLIC _MMX_DestBlend_InvDestColor
  493. _MMX_DestBlend_InvDestColor:
  494. ;*pR = (0xff - (UINT16)RGBA_GETRED(DestC) )*((UINT16)RGBA_GETRED(DestC) );
  495. ;*pG = (0xff - (UINT16)RGBA_GETGREEN(DestC))*((UINT16)RGBA_GETGREEN(DestC));
  496. ;*pB = (0xff - (UINT16)RGBA_GETBLUE(DestC) )*((UINT16)RGBA_GETBLUE(DestC) );
  497. ;*pA = (0xff - (UINT16)RGBA_GETALPHA(DestC))*((UINT16)RGBA_GETALPHA(DestC));
  498. pcmpeqw mm2, mm2
  499. psrlw mm2, 8
  500. psubw mm2, mm3
  501. pmullw mm2, mm3
  502. movq mm1, mm2
  503. ret
  504. ;}
  505. ;-----------------------------------------------------------------------------
  506. ;
  507. ; DestBlendSrcAlphaSat
  508. ;
  509. ; f = min(As, 1-Ad); (f, f, f, 1) * Dest
  510. ;
  511. ;-----------------------------------------------------------------------------
  512. ;void DestBlendSrcAlphaSat(PUINT16 pR, PUINT16 pG, PUINT16 pB, PUINT16 pA, D3DCOLOR DestC, PD3DI_RASTCTX pCtx)
  513. ;{
  514. PUBLIC _MMX_DestBlend_SrcAlphaSat
  515. _MMX_DestBlend_SrcAlphaSat:
  516. ; TBD need to write this code also.
  517. ;UINT16 f = min(pCtx->SI.uBA>>8, 0xff - (UINT16)RGBA_GETALPHA(DestC));
  518. psrlw mm1, 8
  519. pcmpeqw mm2, mm2
  520. psrlw mm2, 8
  521. psubw mm2, mm3
  522. movq mm7, mm1
  523. ; This does min. Only interested in alpha in this anyway.
  524. pcmpgtw mm7, mm2 ; mask true if DestCA < uBA
  525. pand mm2, mm7 ;
  526. pandn mm7, mm1 ;
  527. por mm2, mm7
  528. punpckhwd mm2, mm2 ; Replicate alpha
  529. punpckhdq mm2, mm2 ; Replicate alpha again
  530. ; Make alpha value b
  531. pand mm2, MMWORD PTR Val0x0000ffffffffffff
  532. por mm2, MMWORD PTR Val0x0100000000000000
  533. ;*pR = f*((UINT16)RGBA_GETRED(DestC) );
  534. ;*pG = f*((UINT16)RGBA_GETGREEN(DestC));
  535. ;*pB = f*((UINT16)RGBA_GETBLUE(DestC) );
  536. ;*pA = (UINT16)RGBA_GETALPHA(DestC);
  537. pmullw mm3, mm2
  538. movq mm1, mm3
  539. ret
  540. ;}
  541. END