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.

370 lines
16 KiB

  1. //-----------------------------------------------------------------------------
  2. //
  3. // This file contains texture blending functions.
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997.
  6. //
  7. //-----------------------------------------------------------------------------
  8. include(`m4hdr.mh')dnl
  9. #include "pch.cpp"
  10. #pragma hdrstop
  11. #include "mtxbd_mh.h"
  12. //-----------------------------------------------------------------------------
  13. //
  14. // TexBlend_Tex1_None
  15. //
  16. // cPix = cSrc
  17. // aPix = aSrc
  18. //
  19. //-----------------------------------------------------------------------------
  20. void CMMX_TexBlend_Tex1_None(PD3DI_RASTCTX pCtx, PD3DI_RASTPRIM pP,
  21. PD3DI_RASTSPAN pS)
  22. {
  23. pCtx->SI.uBB = pS->uB;
  24. pCtx->SI.uBG = pS->uG;
  25. pCtx->SI.uBR = pS->uR;
  26. pCtx->SI.uBA = pS->uA;
  27. pCtx->pfnTexBlendEnd(pCtx, pP, pS);
  28. }
  29. //-----------------------------------------------------------------------------
  30. //
  31. // TexBlend_Tex1_Decal
  32. //
  33. // cPix = cTex
  34. // aPix = aTex
  35. //
  36. //-----------------------------------------------------------------------------
  37. void CMMX_TexBlend_Tex1_Decal(PD3DI_RASTCTX pCtx, PD3DI_RASTPRIM pP,
  38. PD3DI_RASTSPAN pS)
  39. {
  40. pCtx->SI.uBB = (UINT16)(RGBA_GETBLUE(pCtx->SI.TexCol[0]) << COLOR_SHIFT);
  41. pCtx->SI.uBG = (UINT16)(RGBA_GETGREEN(pCtx->SI.TexCol[0])<< COLOR_SHIFT);
  42. pCtx->SI.uBR = (UINT16)(RGBA_GETRED(pCtx->SI.TexCol[0]) << COLOR_SHIFT);
  43. pCtx->SI.uBA = (UINT16)(RGBA_GETALPHA(pCtx->SI.TexCol[0])<< COLOR_SHIFT);
  44. pCtx->pfnTexBlendEnd(pCtx, pP, pS);
  45. }
  46. //-----------------------------------------------------------------------------
  47. //
  48. // TexBlend_Tex1_Modulate
  49. //
  50. // cPix = cSrc * cTex
  51. // aPix = aTex
  52. //
  53. //-----------------------------------------------------------------------------
  54. void CMMX_TexBlend_Tex1_Modulate(PD3DI_RASTCTX pCtx, PD3DI_RASTPRIM pP,
  55. PD3DI_RASTSPAN pS)
  56. {
  57. UINT16 uB = pS->uB>>COLOR_SHIFT;
  58. UINT16 uG = pS->uG>>COLOR_SHIFT;
  59. UINT16 uR = pS->uR>>COLOR_SHIFT;
  60. UINT16 uTB = (UINT16)(RGBA_GETBLUE(pCtx->SI.TexCol[0]));
  61. UINT16 uTG = (UINT16)(RGBA_GETGREEN(pCtx->SI.TexCol[0]));
  62. UINT16 uTR = (UINT16)(RGBA_GETRED(pCtx->SI.TexCol[0]));
  63. UINT16 uTA = (UINT16)(RGBA_GETALPHA(pCtx->SI.TexCol[0]));
  64. // this is a PMULLW, which works on unsigned 16 bit quantities
  65. pCtx->SI.uBB = uB*uTB;
  66. pCtx->SI.uBG = uG*uTG;
  67. pCtx->SI.uBR = uR*uTR;
  68. pCtx->SI.uBA = uTA<<COLOR_SHIFT;
  69. pCtx->pfnTexBlendEnd(pCtx, pP, pS);
  70. }
  71. //-----------------------------------------------------------------------------
  72. //
  73. // TexBlend_Tex1_ModulateAlphaOVR
  74. //
  75. // cPix = cSrc * cTex
  76. // aPix = aSrc
  77. //
  78. //-----------------------------------------------------------------------------
  79. void CMMX_TexBlend_Tex1_ModulateAlphaOVR(PD3DI_RASTCTX pCtx, PD3DI_RASTPRIM pP,
  80. PD3DI_RASTSPAN pS)
  81. {
  82. UINT16 uB = pS->uB>>COLOR_SHIFT;
  83. UINT16 uG = pS->uG>>COLOR_SHIFT;
  84. UINT16 uR = pS->uR>>COLOR_SHIFT;
  85. UINT16 uTB = (UINT16)(RGBA_GETBLUE(pCtx->SI.TexCol[0]));
  86. UINT16 uTG = (UINT16)(RGBA_GETGREEN(pCtx->SI.TexCol[0]));
  87. UINT16 uTR = (UINT16)(RGBA_GETRED(pCtx->SI.TexCol[0]));
  88. // this is a PMULLW, which works on unsigned 16 bit quantities
  89. pCtx->SI.uBB = uB*uTB;
  90. pCtx->SI.uBG = uG*uTG;
  91. pCtx->SI.uBR = uR*uTR;
  92. pCtx->SI.uBA = pS->uA;
  93. pCtx->pfnTexBlendEnd(pCtx, pP, pS);
  94. }
  95. //-----------------------------------------------------------------------------
  96. //
  97. // TexBlend_Tex1_Gen
  98. //
  99. // Calls first set of function pointers to do general texture blending.
  100. //
  101. //-----------------------------------------------------------------------------
  102. void CMMX_TexBlend_Tex1_Gen(PD3DI_RASTCTX pCtx, PD3DI_RASTPRIM pP,
  103. PD3DI_RASTSPAN pS)
  104. {
  105. // Initialize input to diffuse color (the default)
  106. D3DI_RASTCOLOR Input = *(D3DI_RASTCOLOR*)&pS->uB;
  107. D3DI_RASTCOLOR Arg1;
  108. D3DI_RASTCOLOR Arg2;
  109. pCtx->pfnTexBlendGetAlpha[0](&Arg1, &Arg2, &Input, pCtx, pS, 0);
  110. pCtx->pfnTexBlendOpAlpha[0]((D3DI_RASTCOLOR*)&pCtx->SI.uBB, &Arg1, &Arg2, pCtx, pS, 0);
  111. pCtx->pfnTexBlendGetColor[0](&Arg1, &Arg2, &Input, pCtx, pS, 0);
  112. pCtx->pfnTexBlendOpColor[0]((D3DI_RASTCOLOR*)&pCtx->SI.uBB, &Arg1, &Arg2, pCtx, pS, 0);
  113. pCtx->pfnTexBlendEnd(pCtx, pP, pS);
  114. }
  115. //-----------------------------------------------------------------------------
  116. //
  117. // TexBlend_TexM_Gen
  118. //
  119. // Does general multi-texture blending.
  120. //
  121. //-----------------------------------------------------------------------------
  122. void CMMX_TexBlend_TexM_Gen(PD3DI_RASTCTX pCtx, PD3DI_RASTPRIM pP,
  123. PD3DI_RASTSPAN pS)
  124. {
  125. // Initialize input to diffuse color (the default)
  126. D3DI_RASTCOLOR Input0 = *(D3DI_RASTCOLOR*)&pS->uB;
  127. D3DI_RASTCOLOR Input1;
  128. D3DI_RASTCOLOR Arg1;
  129. D3DI_RASTCOLOR Arg2;
  130. pCtx->pfnTexBlendGetAlpha[0](&Arg1, &Arg2, &Input0, pCtx, pS, 0);
  131. pCtx->pfnTexBlendOpAlpha[0](&Input1, &Arg1, &Arg2, pCtx, pS, 0);
  132. pCtx->pfnTexBlendGetColor[0](&Arg1, &Arg2, &Input0, pCtx, pS, 0);
  133. pCtx->pfnTexBlendOpColor[0](&Input1, &Arg1, &Arg2, pCtx, pS, 0);
  134. pCtx->pfnTexBlendGetAlpha[1](&Arg1, &Arg2, &Input1, pCtx, pS, 1);
  135. pCtx->pfnTexBlendOpAlpha[1]((D3DI_RASTCOLOR*)&pCtx->SI.uBB, &Arg1, &Arg2, pCtx, pS, 1);
  136. pCtx->pfnTexBlendGetColor[1](&Arg1, &Arg2, &Input1, pCtx, pS, 1);
  137. pCtx->pfnTexBlendOpColor[1]((D3DI_RASTCOLOR*)&pCtx->SI.uBB, &Arg1, &Arg2, pCtx, pS, 1);
  138. pCtx->pfnTexBlendEnd(pCtx, pP, pS);
  139. }
  140. dnl
  141. dnl d_TexBlendGetAlpha
  142. dnl
  143. dnl Generates all the differentiated texture alpha blend gets.
  144. dnl
  145. dnl It takes 2 parameters.
  146. dnl
  147. dnl $1 is one of TextureAlpha, InvTextureAlpha
  148. dnl $2 is one of DiffuseAlpha, InputAlpha, FactorAlpha, InvDiffuseAlpha, InvInputAlpha, InvFactorAlpha
  149. dnl
  150. dnl Assumes that the Arg1 and Arg2 are 8 bit colors, and that Input is a 8.8.
  151. dnl
  152. define(`d_TexBlendGetAlpha', `void CMMX_TexBlend_Get_Alpha_$1_$2(PD3DI_RASTCOLOR pArg1, PD3DI_RASTCOLOR pArg2, PD3DI_RASTCOLOR pInput,
  153. PD3DI_RASTCTX pCtx, PD3DI_RASTSPAN pS, INT32 iTex)
  154. {
  155. ifelse(`$1', `TextureAlpha', `
  156. pArg1->uA = (UINT8)RGBA_GETALPHA(pCtx->SI.TexCol[iTex]);', `$1', `InvTextureAlpha', `
  157. pArg1->uA = (UINT8)~(RGBA_GETALPHA(pCtx->SI.TexCol[iTex]));')
  158. dnl
  159. ifelse(`$2', `DiffuseAlpha', `
  160. pArg2->uA = (UINT8)(pS->uA>>COLOR_SHIFT);', `$2', `InputAlpha', `
  161. pArg2->uA = (UINT8)(pInput->uA>>COLOR_SHIFT);', `$2', `FactorAlpha', `
  162. pArg2->uA = (UINT8)RGBA_GETALPHA(pCtx->pdwRenderState[D3DRENDERSTATE_TEXTUREFACTOR]);', `$2', `InvDiffuseAlpha', `
  163. pArg2->uA = (UINT8)~((pS->uA>>COLOR_SHIFT));', `$2', `InvInputAlpha', `
  164. pArg2->uA = (UINT8)~((pInput->uA>>COLOR_SHIFT));', `$2', `InvFactorAlpha', `
  165. pArg2->uA = (UINT8)~(RGBA_GETALPHA(pCtx->pdwRenderState[D3DRENDERSTATE_TEXTUREFACTOR]));')
  166. }
  167. ')
  168. dnl
  169. d_RepStr(`d_RepStr(`d_TexBlendGetAlpha(AA, BB)',
  170. `AA', TextureAlpha, InvTextureAlpha)',
  171. `BB', DiffuseAlpha, InputAlpha, FactorAlpha, InvDiffuseAlpha, InvInputAlpha, InvFactorAlpha)
  172. dnl
  173. dnl
  174. dnl d_TexBlendOpAlpha
  175. dnl
  176. dnl Generates all the differentiated texture alpha operations.
  177. dnl
  178. dnl It takes 1 parameter.
  179. dnl
  180. dnl $1 is one of None, Copy, Modulate, Modulate2, Modulate4, Add, AddSigned, BlendDiffuseAlpha, BlendTextureAlpha, BlendFactorAlpha
  181. dnl
  182. dnl Assumes that the Arg1 and Arg2 are 8 bit colors. Produces 8.8 output.
  183. dnl
  184. define(`d_TexBlendOpAlpha', `void CMMX_TexBlend_Op_Alpha_$1(PD3DI_RASTCOLOR pOut, PD3DI_RASTCOLOR pArg1, PD3DI_RASTCOLOR pArg2,
  185. PD3DI_RASTCTX pCtx, PD3DI_RASTSPAN pS, INT32 iTex)
  186. {
  187. ifelse(`$1', `None', `
  188. pOut->uA = pS->uA;', `$1', `CopyArg1', `
  189. pOut->uA = pArg1->uA<<COLOR_SHIFT;', `$1', `CopyArg2', `
  190. pOut->uA = pArg2->uA<<COLOR_SHIFT;', `$1', `Modulate', `
  191. pOut->uA = pArg1->uA*pArg2->uA;', `$1', `Modulate2', `
  192. pOut->uA = min(((UINT32)pArg1->uA*pArg2->uA)<<1, 0xffff);', `$1', `Modulate4', `
  193. pOut->uA = min(((UINT32)pArg1->uA*pArg2->uA)<<2, 0xffff);', `$1', `Add', `
  194. pOut->uA = min(((UINT32)pArg1->uA+pArg2->uA)<<COLOR_SHIFT, 0xffff);', `$1', `AddSigned', `
  195. pOut->uA = (min(max((INT32)pArg1->uA+pArg2->uA-128, 0x0), 0xff))<<COLOR_SHIFT;', `$1', `BlendDiffuseAlpha', `
  196. INT32 iA = pS->uA>>COLOR_SHIFT;
  197. pOut->uA = (UINT16)(iA*(pArg1->uA - pArg2->uA) + (pArg2->uA<<COLOR_SHIFT));', `$1', `BlendTextureAlpha', `
  198. INT32 iA = RGBA_GETALPHA(pCtx->SI.TexCol[iTex]);
  199. pOut->uA = (UINT16)(iA*(pArg1->uA - pArg2->uA) + (pArg2->uA<<COLOR_SHIFT));', `$1', `BlendFactorAlpha', `
  200. INT32 iA = RGBA_GETALPHA(pCtx->pdwRenderState[D3DRENDERSTATE_TEXTUREFACTOR]);
  201. pOut->uA = (UINT16)(iA*(pArg1->uA - pArg2->uA) + (pArg2->uA<<COLOR_SHIFT));', `$1', `BlendTextureAlphaPM', `
  202. INT32 iA = 255 - RGBA_GETALPHA(pCtx->SI.TexCol[iTex]);
  203. pOut->uA = min((UINT32)((pArg1->uA<<COLOR_SHIFT) + iA*pArg2->uA), 0xffff);')
  204. }
  205. ')
  206. dnl
  207. dnl
  208. d_RepStr(`d_TexBlendOpAlpha(AA)',
  209. `AA', None, CopyArg1, CopyArg2, Modulate, Modulate2, Modulate4, Add, AddSigned,
  210. BlendDiffuseAlpha, BlendTextureAlpha, BlendFactorAlpha, BlendTextureAlphaPM)
  211. dnl
  212. dnl d_TexBlendGetColor
  213. dnl
  214. dnl Generates all the differentiated texture color blend gets.
  215. dnl
  216. dnl It takes 2 parameters.
  217. dnl
  218. dnl $1 is one of Texure, InvTexture, TextureAlpha, InvTextureAlpha
  219. dnl $2 is one of DiffuseAlpha, InputAlpha, FactorAlpha, InvDiffuseAlpha, InvInputAlpha, InvFactorAlpha
  220. dnl
  221. dnl Assumes that the Arg1 and Arg2 are 8 bit colors, and that Input is a 8.8.
  222. dnl
  223. define(`d_TexBlendGetColor', `void CMMX_TexBlend_Get_Color_$1_$2(PD3DI_RASTCOLOR pArg1, PD3DI_RASTCOLOR pArg2, PD3DI_RASTCOLOR pInput,
  224. PD3DI_RASTCTX pCtx, PD3DI_RASTSPAN pS, INT32 iTex)
  225. {
  226. ifelse(`$1', `Texture', `
  227. pArg1->uB = (UINT8)RGBA_GETBLUE(pCtx->SI.TexCol[iTex]);
  228. pArg1->uG = (UINT8)RGBA_GETGREEN(pCtx->SI.TexCol[iTex]);
  229. pArg1->uR = (UINT8)RGBA_GETRED(pCtx->SI.TexCol[iTex]);', `$1', `InvTexture', `
  230. pArg1->uB = (UINT8)~(RGBA_GETBLUE(pCtx->SI.TexCol[iTex]));
  231. pArg1->uG = (UINT8)~(RGBA_GETGREEN(pCtx->SI.TexCol[iTex]));
  232. pArg1->uR = (UINT8)~(RGBA_GETRED(pCtx->SI.TexCol[iTex]));', `$1', `TextureAlpha', `
  233. pArg1->uB = (UINT8)RGBA_GETALPHA(pCtx->SI.TexCol[iTex]);
  234. pArg1->uG = pArg1->uB;
  235. pArg1->uR = pArg1->uB;', `$1', `InvTextureAlpha', `
  236. pArg1->uB = (UINT8)~(RGBA_GETALPHA(pCtx->SI.TexCol[iTex]));
  237. pArg1->uG = pArg1->uB;
  238. pArg1->uR = pArg1->uB;')
  239. dnl
  240. ifelse(`$2', `Diffuse', `
  241. pArg2->uB = (UINT8)(pS->uB>>COLOR_SHIFT);
  242. pArg2->uG = (UINT8)(pS->uG>>COLOR_SHIFT);
  243. pArg2->uR = (UINT8)(pS->uR>>COLOR_SHIFT);', `$2', `Input', `
  244. pArg2->uB = (UINT8)(pInput->uB>>COLOR_SHIFT);
  245. pArg2->uG = (UINT8)(pInput->uG>>COLOR_SHIFT);
  246. pArg2->uR = (UINT8)(pInput->uR>>COLOR_SHIFT);', `$2', `Factor', `
  247. pArg2->uB = (UINT8)RGBA_GETBLUE(pCtx->pdwRenderState[D3DRENDERSTATE_TEXTUREFACTOR]);
  248. pArg2->uG = (UINT8)RGBA_GETGREEN(pCtx->pdwRenderState[D3DRENDERSTATE_TEXTUREFACTOR]);
  249. pArg2->uR = (UINT8)RGBA_GETRED(pCtx->pdwRenderState[D3DRENDERSTATE_TEXTUREFACTOR]);', `$2', `InvDiffuse', `
  250. pArg2->uB = (UINT8)~((pS->uB>>COLOR_SHIFT));
  251. pArg2->uG = (UINT8)~((pS->uG>>COLOR_SHIFT));
  252. pArg2->uR = (UINT8)~((pS->uR>>COLOR_SHIFT));', `$2', `InvInput', `
  253. pArg2->uB = (UINT8)~((pInput->uB>>COLOR_SHIFT));
  254. pArg2->uG = (UINT8)~((pInput->uG>>COLOR_SHIFT));
  255. pArg2->uR = (UINT8)~((pInput->uR>>COLOR_SHIFT));', `$2', `InvFactor', `
  256. pArg2->uB = (UINT8)~(RGBA_GETBLUE(pCtx->pdwRenderState[D3DRENDERSTATE_TEXTUREFACTOR]));
  257. pArg2->uG = (UINT8)~(RGBA_GETGREEN(pCtx->pdwRenderState[D3DRENDERSTATE_TEXTUREFACTOR]));
  258. pArg2->uR = (UINT8)~(RGBA_GETRED(pCtx->pdwRenderState[D3DRENDERSTATE_TEXTUREFACTOR]));', `$2', `DiffuseAlpha', `
  259. pArg2->uB = (UINT8)(pS->uA>>COLOR_SHIFT);
  260. pArg2->uG = pArg2->uB;
  261. pArg2->uR = pArg2->uB;', `$2', `InputAlpha', `
  262. pArg2->uB = (UINT8)(pInput->uA>>COLOR_SHIFT);
  263. pArg2->uG = pArg2->uB;
  264. pArg2->uR = pArg2->uB;', `$2', `FactorAlpha', `
  265. pArg2->uB = (UINT8)RGBA_GETALPHA(pCtx->pdwRenderState[D3DRENDERSTATE_TEXTUREFACTOR]);
  266. pArg2->uG = pArg2->uB;
  267. pArg2->uR = pArg2->uB;', `$2', `InvDiffuseAlpha', `
  268. pArg2->uB = (UINT8)~((pS->uA>>COLOR_SHIFT));
  269. pArg2->uG = pArg2->uB;
  270. pArg2->uR = pArg2->uB;', `$2', `InvInputAlpha', `
  271. pArg2->uB = (UINT8)~((pInput->uA>>COLOR_SHIFT));
  272. pArg2->uG = pArg2->uB;
  273. pArg2->uR = pArg2->uB;', `$2', `InvFactorAlpha', `
  274. pArg2->uB = (UINT8)~(RGBA_GETALPHA(pCtx->pdwRenderState[D3DRENDERSTATE_TEXTUREFACTOR]));
  275. pArg2->uG = pArg2->uB;
  276. pArg2->uR = pArg2->uB;')
  277. }
  278. ')
  279. dnl
  280. d_RepStr(`d_RepStr(`d_TexBlendGetColor(AA, BB)',
  281. `AA', Texture, InvTexture, TextureAlpha, InvTextureAlpha)',
  282. `BB', Diffuse, Input, Factor, InvDiffuse, InvInput, InvFactor,
  283. DiffuseAlpha, InputAlpha, FactorAlpha, InvDiffuseAlpha, InvInputAlpha, InvFactorAlpha)
  284. dnl
  285. dnl
  286. dnl d_TexBlendOpColor
  287. dnl
  288. dnl Generates all the differentiated texture color operations.
  289. dnl
  290. dnl It takes 1 parameter.
  291. dnl
  292. dnl $1 is one of None, Copy, Modulate, Modulate2, Modulate4, Add, AddSigned, BlendDiffuseAlpha, BlendTextureAlpha, BlendFactorAlpha
  293. dnl
  294. dnl Assumes that the inputs are 8 bit colors.
  295. dnl
  296. define(`d_TexBlendOpColor', `void CMMX_TexBlend_Op_Color_$1(PD3DI_RASTCOLOR pOut, PD3DI_RASTCOLOR pArg1, PD3DI_RASTCOLOR pArg2,
  297. PD3DI_RASTCTX pCtx, PD3DI_RASTSPAN pS, INT32 iTex)
  298. {
  299. ifelse(`$1', `None', `
  300. pOut->uB = pS->uB;
  301. pOut->uG = pS->uG;
  302. pOut->uR = pS->uR;', `$1', `CopyArg1', `
  303. pOut->uB = pArg1->uB<<COLOR_SHIFT;
  304. pOut->uG = pArg1->uG<<COLOR_SHIFT;
  305. pOut->uR = pArg1->uR<<COLOR_SHIFT;', `$1', `CopyArg2', `
  306. pOut->uB = pArg2->uB<<COLOR_SHIFT;
  307. pOut->uG = pArg2->uG<<COLOR_SHIFT;
  308. pOut->uR = pArg2->uR<<COLOR_SHIFT;', `$1', `Modulate', `
  309. pOut->uB = pArg1->uB*pArg2->uB;
  310. pOut->uG = pArg1->uG*pArg2->uG;
  311. pOut->uR = pArg1->uR*pArg2->uR;', `$1', `Modulate2', `
  312. pOut->uB = min(((UINT32)pArg1->uB*pArg2->uB)<<1, 0xffff);
  313. pOut->uG = min(((UINT32)pArg1->uG*pArg2->uG)<<1, 0xffff);
  314. pOut->uR = min(((UINT32)pArg1->uR*pArg2->uR)<<1, 0xffff);', `$1', `Modulate4', `
  315. pOut->uB = min(((UINT32)pArg1->uB*pArg2->uB)<<2, 0xffff);
  316. pOut->uG = min(((UINT32)pArg1->uG*pArg2->uG)<<2, 0xffff);
  317. pOut->uR = min(((UINT32)pArg1->uR*pArg2->uR)<<2, 0xffff);', `$1', `Add', `
  318. pOut->uB = min(((UINT32)pArg1->uB+pArg2->uB)<<COLOR_SHIFT, 0xffff);
  319. pOut->uG = min(((UINT32)pArg1->uG+pArg2->uG)<<COLOR_SHIFT, 0xffff);
  320. pOut->uR = min(((UINT32)pArg1->uR+pArg2->uR)<<COLOR_SHIFT, 0xffff);', `$1', `AddSigned', `
  321. pOut->uB = (min(max((INT32)pArg1->uB+pArg2->uB-128, 0x0), 0xff))<<COLOR_SHIFT;
  322. pOut->uG = (min(max((INT32)pArg1->uG+pArg2->uG-128, 0x0), 0xff))<<COLOR_SHIFT;
  323. pOut->uR = (min(max((INT32)pArg1->uR+pArg2->uR-128, 0x0), 0xff))<<COLOR_SHIFT;', `$1', `BlendDiffuseAlpha', `
  324. INT32 iA = pS->uA>>COLOR_SHIFT;
  325. pOut->uB = (UINT16)(iA*(pArg1->uB - pArg2->uB) + (pArg2->uB<<COLOR_SHIFT));
  326. pOut->uG = (UINT16)(iA*(pArg1->uG - pArg2->uG) + (pArg2->uG<<COLOR_SHIFT));
  327. pOut->uR = (UINT16)(iA*(pArg1->uR - pArg2->uR) + (pArg2->uR<<COLOR_SHIFT));', `$1', `BlendTextureAlpha', `
  328. INT32 iA = RGBA_GETALPHA(pCtx->SI.TexCol[iTex]);
  329. pOut->uB = (UINT16)(iA*(pArg1->uB - pArg2->uB) + (pArg2->uB<<COLOR_SHIFT));
  330. pOut->uG = (UINT16)(iA*(pArg1->uG - pArg2->uG) + (pArg2->uG<<COLOR_SHIFT));
  331. pOut->uR = (UINT16)(iA*(pArg1->uR - pArg2->uR) + (pArg2->uR<<COLOR_SHIFT));', `$1', `BlendFactorAlpha', `
  332. INT32 iA = RGBA_GETALPHA(pCtx->pdwRenderState[D3DRENDERSTATE_TEXTUREFACTOR]);
  333. pOut->uB = (UINT16)(iA*(pArg1->uB - pArg2->uB) + (pArg2->uB<<COLOR_SHIFT));
  334. pOut->uG = (UINT16)(iA*(pArg1->uG - pArg2->uG) + (pArg2->uG<<COLOR_SHIFT));
  335. pOut->uR = (UINT16)(iA*(pArg1->uR - pArg2->uR) + (pArg2->uR<<COLOR_SHIFT));', `$1', `BlendTextureAlphaPM', `
  336. INT32 iA = 255 - RGBA_GETALPHA(pCtx->SI.TexCol[iTex]);
  337. pOut->uB = min((UINT32)((pArg1->uB<<COLOR_SHIFT) + iA*pArg2->uB), 0xffff);
  338. pOut->uG = min((UINT32)((pArg1->uG<<COLOR_SHIFT) + iA*pArg2->uG), 0xffff);
  339. pOut->uR = min((UINT32)((pArg1->uR<<COLOR_SHIFT) + iA*pArg2->uR), 0xffff);')
  340. }
  341. ')
  342. dnl
  343. dnl
  344. d_RepStr(`d_TexBlendOpColor(AA)',
  345. `AA', None, CopyArg1, CopyArg2, Modulate, Modulate2, Modulate4, Add, AddSigned,
  346. BlendDiffuseAlpha, BlendTextureAlpha, BlendFactorAlpha, BlendTextureAlphaPM)