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.

1117 lines
40 KiB

  1. #include "pch.cpp"
  2. #pragma hdrstop
  3. #include "light.h"
  4. #include "clipper.h"
  5. #include "drawprim.hpp"
  6. #define NEXT(pointer, stride, type) pointer = (type*)((char*)pointer + stride);
  7. // We use power of 2 because it preserves the mantissa when we multiply
  8. const D3DVALUE __HUGE_PWR2 = 1024.0f*1024.0f*2.0f;
  9. const D3DVALUE __ONE_OVER_255 = 1.0f/255.0f;
  10. //--------------------------------------------------------------------------
  11. D3DVALUE ComputeDistance(LPD3DFE_PROCESSVERTICES pv, D3DVECTOR &v)
  12. {
  13. if (pv->dwFlags & D3DPV_RANGEBASEDFOG)
  14. {
  15. D3DVALUE x,y,z;
  16. x = v.x*pv->mWV._11 + v.y*pv->mWV._21 + v.z*pv->mWV._31 + pv->mWV._41;
  17. y = v.x*pv->mWV._12 + v.y*pv->mWV._22 + v.z*pv->mWV._32 + pv->mWV._42;
  18. z = v.x*pv->mWV._13 + v.y*pv->mWV._23 + v.z*pv->mWV._33 + pv->mWV._43;
  19. return SQRTF(x*x + y*y + z*z);
  20. }
  21. else
  22. return v.x*pv->mWV._13 + v.y*pv->mWV._23 + v.z*pv->mWV._33 + pv->mWV._43;
  23. }
  24. //--------------------------------------------------------------------------
  25. // Process vertices with flexible vertex format, if vertex is
  26. // contiguous
  27. //
  28. // The following fields from pv are used:
  29. // dwFlags
  30. // dwNumVertices
  31. // position.lpvData
  32. // position.lpvStrides
  33. // dwVIDIn
  34. // dwVIDOut
  35. // lpvOut
  36. // lpClipFlags
  37. // nTexCoord
  38. // Returns:
  39. // returns dwClipIntersection or 0 (if D3DDP_DONOTCLIP is set)
  40. // Side effects:
  41. // dwClipUnion, dwClipIntersection are set only if D3DDP_DONOTCLIP is not set
  42. // rExtents is updated if D3DDP_DONOTUPDATEEXTENTS is not set
  43. //
  44. #undef DPF_MODNAME
  45. #define DPF_MODNAME "ProcessVerticesFVF"
  46. DWORD ProcessVerticesFVF (LPD3DFE_PROCESSVERTICES pv)
  47. {
  48. D3DVERTEX *in = (D3DVERTEX*)pv->position.lpvData;
  49. DWORD in_size = pv->position.dwStride;
  50. D3DTLVERTEX *out = (D3DTLVERTEX*)pv->lpvOut;
  51. DWORD out_size = pv->dwOutputSize;
  52. D3DFE_CLIPCODE *hout = pv->lpClipFlags;
  53. DWORD flags = pv->dwFlags;
  54. DWORD inVID = pv->dwVIDIn;
  55. DWORD outVID = pv->dwVIDOut;
  56. int nTex = pv->nTexCoord << 1;
  57. int i;
  58. int clip_intersection = ~0;
  59. int clip_union = 0;
  60. D3DVALUE minx, maxx, miny, maxy;
  61. DWORD texOffset;
  62. DWORD diffuseOffset;
  63. DWORD specularOffset;
  64. int count = pv->dwNumVertices;
  65. BOOL bNoFVFandNoTexture = FALSE;
  66. // Compute input offsets
  67. i = sizeof(D3DVECTOR);
  68. if (inVID & D3DFVF_NORMAL)
  69. i += sizeof(D3DVECTOR);
  70. if (inVID & D3DFVF_RESERVED1)
  71. i += sizeof(D3DVALUE);
  72. diffuseOffset = i;
  73. if (inVID & D3DFVF_DIFFUSE)
  74. i += sizeof(DWORD);
  75. specularOffset = i;
  76. if (inVID & D3DFVF_SPECULAR)
  77. i += sizeof(DWORD);
  78. texOffset = i;
  79. if (!(pv->dwDeviceFlags & D3DDEV_FVF || pv->dwFlags & D3DPV_VBCALL))
  80. {
  81. if (nTex)
  82. {
  83. texOffset += pv->dwTextureIndexToCopy << 3;
  84. }
  85. else
  86. {
  87. // For non-FVF drivers we have to fill texture coordinates with
  88. // zeros.
  89. bNoFVFandNoTexture = TRUE;
  90. }
  91. }
  92. if (!(flags & D3DDP_DONOTUPDATEEXTENTS))
  93. {
  94. minx = pv->rExtents.x1;
  95. miny = pv->rExtents.y1;
  96. maxx = pv->rExtents.x2;
  97. maxy = pv->rExtents.y2;
  98. }
  99. pv->lighting.outDiffuse = __DEFAULT_DIFFUSE;
  100. pv->lighting.outSpecular = __DEFAULT_SPECULAR;
  101. for (i = count; i; i--)
  102. {
  103. DWORD clip;
  104. float x, y, z, w, we;
  105. x = in->x*pv->mCTM._11 + in->y*pv->mCTM._21 +
  106. in->z*pv->mCTM._31 + pv->mCTM._41;
  107. y = in->x*pv->mCTM._12 + in->y*pv->mCTM._22 +
  108. in->z*pv->mCTM._32 + pv->mCTM._42;
  109. z = in->x*pv->mCTM._13 + in->y*pv->mCTM._23 +
  110. in->z*pv->mCTM._33 + pv->mCTM._43;
  111. we= in->x*pv->mCTM._14 + in->y*pv->mCTM._24 +
  112. in->z*pv->mCTM._34 + pv->mCTM._44;
  113. clip = 0;
  114. if (!(flags & D3DDP_DONOTCLIP))
  115. {
  116. D3DVALUE xx = we - x;
  117. D3DVALUE yy = we - y;
  118. D3DVALUE zz = we - z;
  119. clip = ((ASINT32(x) & 0x80000000) >> (32-D3DCLIP_LEFTBIT)) |
  120. ((ASINT32(y) & 0x80000000) >> (32-D3DCLIP_BOTTOMBIT)) |
  121. ((ASINT32(z) & 0x80000000) >> (32-D3DCLIP_FRONTBIT)) |
  122. ((ASINT32(xx) & 0x80000000) >> (32-D3DCLIP_RIGHTBIT)) |
  123. ((ASINT32(yy) & 0x80000000) >> (32-D3DCLIP_TOPBIT)) |
  124. ((ASINT32(zz) & 0x80000000) >> (32-D3DCLIP_BACKBIT));
  125. }
  126. if (clip == 0)
  127. {
  128. int k;
  129. DWORD *pOut = (DWORD*)((char*)out + 4*sizeof(D3DVALUE));
  130. // We have to check this only for DONOTCLIP case, because otherwise
  131. // "clip" is not zero, if we is zero.
  132. if (!FLOAT_EQZ(we))
  133. w = D3DVAL(1)/we;
  134. else
  135. w = __HUGE_PWR2;
  136. clip_intersection = 0;
  137. if (!(flags & D3DDP_DONOTUPDATEEXTENTS))
  138. {
  139. x = x * w * pv->vcache.scaleX + pv->vcache.offsetX;
  140. y = y * w * pv->vcache.scaleY + pv->vcache.offsetY;
  141. if (x < minx) minx = x;
  142. if (x > maxx) maxx = x;
  143. if (y < miny) miny = y;
  144. if (y > maxy) maxy = y;
  145. }
  146. else
  147. {
  148. x = x * w * pv->vcache.scaleX + pv->vcache.offsetX;
  149. y = y * w * pv->vcache.scaleY + pv->vcache.offsetY;
  150. }
  151. out->sx = x;
  152. out->sy = y;
  153. out->sz = z*w;
  154. out->rhw = w;
  155. if (flags & D3DPV_LIGHTING)
  156. {
  157. if (pv->dwFlags & D3DPV_COLORVERTEX)
  158. {
  159. DWORD color = *(D3DCOLOR*)((char*)in+diffuseOffset);
  160. pv->lighting.alpha = color & 0xFF000000;
  161. MakeColor(&pv->lighting.vertexDiffuse, color);
  162. }
  163. if (pv->dwFlags & D3DPV_COLORVERTEXS)
  164. {
  165. MakeColor(&pv->lighting.vertexSpecular,
  166. *(D3DCOLOR*)((char*)in+specularOffset));
  167. }
  168. LIGHT_VERTEX(pv, in);
  169. }
  170. else
  171. if (inVID & (D3DFVF_DIFFUSE | D3DFVF_SPECULAR))
  172. {
  173. if (inVID & D3DFVF_DIFFUSE)
  174. pv->lighting.outDiffuse = *(D3DCOLOR*)((char*)in+diffuseOffset);
  175. if (inVID & D3DFVF_SPECULAR)
  176. pv->lighting.outSpecular = *(D3DCOLOR*)((char*)in+specularOffset);
  177. }
  178. if (flags & D3DPV_FOG)
  179. {
  180. D3DVALUE d = ComputeDistance(pv, *(D3DVECTOR*)in);
  181. FOG_VERTEX(&pv->lighting, d);
  182. }
  183. if (outVID & D3DFVF_DIFFUSE)
  184. *pOut++ = pv->lighting.outDiffuse;
  185. if (outVID & D3DFVF_SPECULAR)
  186. *pOut++ = pv->lighting.outSpecular;
  187. if (bNoFVFandNoTexture)
  188. {
  189. *(D3DVALUE*)pOut++ = 0;
  190. *(D3DVALUE*)pOut = 0;
  191. }
  192. else
  193. {
  194. DWORD *pIn = (DWORD*)((char*)in+texOffset);
  195. for (k=0; k < nTex; k++)
  196. *pOut++ = *pIn++;
  197. }
  198. }
  199. else
  200. {
  201. if (pv->dwDeviceFlags & D3DDEV_GUARDBAND)
  202. {
  203. D3DVALUE xnew = x * pv->vcache.gb11 + we * pv->vcache.gb41;
  204. D3DVALUE ynew = y * pv->vcache.gb22 + we * pv->vcache.gb42;
  205. D3DVALUE xx = we - xnew;
  206. D3DVALUE yy = we - ynew;
  207. clip |= ((ASINT32(xnew) & 0x80000000) >> (32-D3DCLIPGB_LEFTBIT)) |
  208. ((ASINT32(ynew) & 0x80000000) >> (32-D3DCLIPGB_BOTTOMBIT)) |
  209. ((ASINT32(xx) & 0x80000000) >> (32-D3DCLIPGB_RIGHTBIT)) |
  210. ((ASINT32(yy) & 0x80000000) >> (32-D3DCLIPGB_TOPBIT));
  211. }
  212. clip_intersection &= clip;
  213. clip_union |= clip;
  214. out->sx = x;
  215. out->sy = y;
  216. out->sz = z;
  217. out->rhw = we;
  218. }
  219. if (!(flags & D3DDP_DONOTCLIP))
  220. *hout++ = (D3DFE_CLIPCODE)clip;
  221. in = (D3DVERTEX*) ((char*) in + in_size);
  222. out = (D3DTLVERTEX*) ((char*) out + out_size);
  223. }
  224. if (!(flags & D3DDP_DONOTCLIP) && !clip_intersection && clip_union)
  225. { // We have to light all clipped vertices
  226. int n;
  227. D3DVERTEX *in = (D3DVERTEX*)pv->position.lpvData;
  228. D3DTLVERTEX *out = (D3DTLVERTEX*)pv->lpvOut;
  229. D3DFE_CLIPCODE *hout = pv->lpClipFlags;
  230. for (n = count; n ; n--)
  231. {
  232. if (*hout)
  233. {
  234. // pOut pointes to the first D3DVALUE after W
  235. DWORD *pOut = (DWORD*)((char*)out + 4*sizeof(D3DVALUE));
  236. int k;
  237. if (pv->dwDeviceFlags & D3DDEV_GUARDBAND &&
  238. (*hout & ~__D3DCLIP_INGUARDBAND) == 0)
  239. { // This vertex is inside the guard band. We have to compute
  240. // screen coordinates for it
  241. D3DVALUE w = D3DVAL(1)/out->rhw;
  242. if (!(flags & D3DDP_DONOTUPDATEEXTENTS))
  243. {
  244. D3DVALUE x = out->sx * w * pv->vcache.scaleX + pv->vcache.offsetX;
  245. D3DVALUE y = out->sy * w * pv->vcache.scaleY + pv->vcache.offsetY;
  246. if (x < minx) minx = x;
  247. if (x > maxx) maxx = x;
  248. if (y < miny) miny = y;
  249. if (y > maxy) maxy = y;
  250. out->sx = x;
  251. out->sy = y;
  252. }
  253. else
  254. {
  255. out->sx = out->sx * w * pv->vcache.scaleX + pv->vcache.offsetX;
  256. out->sy = out->sy * w * pv->vcache.scaleY + pv->vcache.offsetY;
  257. }
  258. out->sz *= w;
  259. out->rhw = w;
  260. }
  261. if (flags & D3DPV_LIGHTING)
  262. {
  263. if (pv->dwFlags & D3DPV_COLORVERTEX)
  264. {
  265. DWORD color = *(D3DCOLOR*)((char*)in+diffuseOffset);
  266. pv->lighting.alpha = color & 0xFF000000;
  267. MakeColor(&pv->lighting.vertexDiffuse, color);
  268. }
  269. if (pv->dwFlags & D3DPV_COLORVERTEXS)
  270. {
  271. MakeColor(&pv->lighting.vertexSpecular,
  272. *(D3DCOLOR*)((char*)in+specularOffset));
  273. }
  274. LIGHT_VERTEX(pv, in);
  275. }
  276. else
  277. if (inVID & (D3DFVF_DIFFUSE | D3DFVF_SPECULAR))
  278. {
  279. if (inVID & D3DFVF_DIFFUSE)
  280. pv->lighting.outDiffuse = *(D3DCOLOR*)((char*)in+diffuseOffset);
  281. if (inVID & D3DFVF_SPECULAR)
  282. pv->lighting.outSpecular = *(D3DCOLOR*)((char*)in+specularOffset);
  283. }
  284. if (flags & D3DPV_FOG)
  285. {
  286. D3DVALUE d = ComputeDistance(pv, *(D3DVECTOR*)in);
  287. FOG_VERTEX(&pv->lighting, d);
  288. }
  289. if (outVID & D3DFVF_DIFFUSE)
  290. *pOut++ = pv->lighting.outDiffuse;
  291. if (outVID & D3DFVF_SPECULAR)
  292. *pOut++ = pv->lighting.outSpecular;
  293. if (bNoFVFandNoTexture)
  294. {
  295. *(D3DVALUE*)pOut++ = 0;
  296. *(D3DVALUE*)pOut = 0;
  297. }
  298. else
  299. {
  300. DWORD *pIn = (DWORD*)((char*)in+texOffset);
  301. for (k=0; k < nTex; k++)
  302. *pOut++ = *pIn++;
  303. }
  304. }
  305. in = (D3DVERTEX*) ((char*) in + in_size);
  306. out = (D3DTLVERTEX*) ((char*) out + out_size);
  307. hout++;
  308. }
  309. }
  310. if (!(flags & D3DDP_DONOTUPDATEEXTENTS))
  311. {
  312. /*
  313. * extend to cover lines.
  314. */
  315. maxx += pv->dvExtentsAdjust;
  316. maxy += pv->dvExtentsAdjust;
  317. minx -= pv->dvExtentsAdjust;
  318. miny -= pv->dvExtentsAdjust;
  319. /* Clamp to viewport */
  320. if (minx < pv->vcache.minX)
  321. minx = pv->vcache.minX;
  322. if (miny < pv->vcache.minY)
  323. miny = pv->vcache.minY;
  324. if (maxx > pv->vcache.maxX)
  325. maxx = pv->vcache.maxX;
  326. if (maxy > pv->vcache.maxY)
  327. maxy = pv->vcache.maxY;
  328. pv->rExtents.x1 = minx;
  329. pv->rExtents.y1 = miny;
  330. pv->rExtents.x2 = maxx;
  331. pv->rExtents.y2 = maxy;
  332. }
  333. if (!(flags & D3DDP_DONOTCLIP))
  334. {
  335. pv->dwClipIntersection = clip_intersection;
  336. pv->dwClipUnion = clip_union;
  337. }
  338. else
  339. {
  340. pv->dwClipIntersection = 0;
  341. pv->dwClipUnion = 0;
  342. }
  343. return 0;
  344. }
  345. //--------------------------------------------------------------------------
  346. // Process vertices with flexible vertex format and strides
  347. //
  348. // The following fields from pv are used:
  349. // dwFlags
  350. // dwNumVertices
  351. // all pointer and strides
  352. // position.lpvStrides
  353. // dwVIDIn
  354. // dwVIDOut
  355. // lpvOut
  356. // lpClipFlags
  357. // nTexCoord
  358. // Returns:
  359. // returns dwClipIntersection or 0 (if D3DDP_DONOTCLIP is set)
  360. // Side effects:
  361. // dwClipUnion, dwClipIntersection are set only if D3DDP_DONOTCLIP is not set
  362. // rExtents is updated if D3DDP_DONOTUPDATEEXTENTS is not set
  363. //
  364. #undef DPF_MODNAME
  365. #define DPF_MODNAME "ProcessVerticesFVFS"
  366. DWORD ProcessVerticesFVFS (LPD3DFE_PROCESSVERTICES pv)
  367. {
  368. D3DVECTOR *in;
  369. D3DVECTOR *inNormal;
  370. DWORD *inDiffuse;
  371. DWORD *inSpecular;
  372. D3DVALUE *inTexture[8];
  373. D3DTLVERTEX *out = (D3DTLVERTEX*)pv->lpvOut;
  374. DWORD out_size = pv->dwOutputSize;
  375. D3DFE_CLIPCODE *hout = pv->lpClipFlags;
  376. DWORD flags = pv->dwFlags;
  377. DWORD inVID = pv->dwVIDIn;
  378. DWORD outVID = pv->dwVIDOut;
  379. int nTex = pv->nTexCoord;
  380. int i;
  381. int clip_intersection = ~0;
  382. int clip_union = 0;
  383. D3DVALUE minx, maxx, miny, maxy;
  384. int count = pv->dwNumVertices;
  385. BOOL bNoFVFandNoTexture = FALSE;
  386. D3DLIGHTINGELEMENT le;
  387. in = (D3DVECTOR*)pv->position.lpvData;
  388. inNormal = (D3DVECTOR*)pv->normal.lpvData;
  389. inDiffuse = (DWORD*)pv->diffuse.lpvData;
  390. inSpecular = (DWORD*)pv->specular.lpvData;
  391. if (pv->dwDeviceFlags & D3DDEV_FVF || pv->dwFlags & D3DPV_VBCALL)
  392. {
  393. for (i=0; i < nTex; i++)
  394. inTexture[i] = (D3DVALUE*)pv->textures[i].lpvData;
  395. }
  396. else
  397. {
  398. if (nTex)
  399. inTexture[0] = (D3DVALUE*)pv->textures[pv->dwTextureIndexToCopy].lpvData;
  400. else
  401. {
  402. // For non-FVF drivers we have to fill texture coordinates with
  403. // zeros.
  404. bNoFVFandNoTexture = TRUE;
  405. }
  406. }
  407. if (!(flags & D3DDP_DONOTUPDATEEXTENTS))
  408. {
  409. minx = pv->rExtents.x1;
  410. miny = pv->rExtents.y1;
  411. maxx = pv->rExtents.x2;
  412. maxy = pv->rExtents.y2;
  413. }
  414. pv->lighting.outDiffuse = __DEFAULT_DIFFUSE;
  415. pv->lighting.outSpecular = __DEFAULT_SPECULAR;
  416. for (i = count; i; i--)
  417. {
  418. int clip;
  419. float x, y, z, w, we;
  420. x = in->x*pv->mCTM._11 + in->y*pv->mCTM._21 +
  421. in->z*pv->mCTM._31 + pv->mCTM._41;
  422. y = in->x*pv->mCTM._12 + in->y*pv->mCTM._22 +
  423. in->z*pv->mCTM._32 + pv->mCTM._42;
  424. z = in->x*pv->mCTM._13 + in->y*pv->mCTM._23 +
  425. in->z*pv->mCTM._33 + pv->mCTM._43;
  426. we= in->x*pv->mCTM._14 + in->y*pv->mCTM._24 +
  427. in->z*pv->mCTM._34 + pv->mCTM._44;
  428. clip = 0;
  429. if (!(flags & D3DDP_DONOTCLIP))
  430. {
  431. D3DVALUE xx = we - x;
  432. D3DVALUE yy = we - y;
  433. D3DVALUE zz = we - z;
  434. clip = ((ASINT32(x) & 0x80000000) >> (32-D3DCLIP_LEFTBIT)) |
  435. ((ASINT32(y) & 0x80000000) >> (32-D3DCLIP_BOTTOMBIT)) |
  436. ((ASINT32(z) & 0x80000000) >> (32-D3DCLIP_FRONTBIT)) |
  437. ((ASINT32(xx) & 0x80000000) >> (32-D3DCLIP_RIGHTBIT)) |
  438. ((ASINT32(yy) & 0x80000000) >> (32-D3DCLIP_TOPBIT)) |
  439. ((ASINT32(zz) & 0x80000000) >> (32-D3DCLIP_BACKBIT));
  440. }
  441. if (clip == 0)
  442. {
  443. int k;
  444. DWORD *pOut = (DWORD*)((char*)out + 4*sizeof(D3DVALUE));
  445. // We have to check this only for DONOTCLIP case, because otherwise
  446. // "clip" is not zero, if we is zero.
  447. if (!FLOAT_EQZ(we))
  448. w = D3DVAL(1)/we;
  449. else
  450. w = __HUGE_PWR2;
  451. clip_intersection = 0;
  452. if (!(flags & D3DDP_DONOTUPDATEEXTENTS))
  453. {
  454. x = x * w * pv->vcache.scaleX + pv->vcache.offsetX;
  455. y = y * w * pv->vcache.scaleY + pv->vcache.offsetY;
  456. if (x < minx) minx = x;
  457. if (x > maxx) maxx = x;
  458. if (y < miny) miny = y;
  459. if (y > maxy) maxy = y;
  460. }
  461. else
  462. {
  463. x = x * w * pv->vcache.scaleX + pv->vcache.offsetX;
  464. y = y * w * pv->vcache.scaleY + pv->vcache.offsetY;
  465. }
  466. out->sx = x;
  467. out->sy = y;
  468. out->sz = z*w;
  469. out->rhw = w;
  470. if (flags & D3DPV_LIGHTING)
  471. {
  472. le.dvPosition = *in;
  473. le.dvNormal = *inNormal;
  474. if (pv->dwFlags & D3DPV_COLORVERTEX)
  475. {
  476. pv->lighting.alpha = *inDiffuse & 0xFF000000;
  477. MakeColor(&pv->lighting.vertexDiffuse, *inDiffuse);
  478. }
  479. if (pv->dwFlags & D3DPV_COLORVERTEXS)
  480. {
  481. MakeColor(&pv->lighting.vertexSpecular, *inSpecular);
  482. }
  483. LIGHT_VERTEX(pv, &le);
  484. }
  485. else
  486. if (inVID & (D3DFVF_DIFFUSE | D3DFVF_SPECULAR))
  487. {
  488. if (inVID & D3DFVF_DIFFUSE)
  489. pv->lighting.outDiffuse = *inDiffuse;
  490. if (inVID & D3DFVF_SPECULAR)
  491. pv->lighting.outSpecular = *inSpecular;
  492. }
  493. if (flags & D3DPV_FOG)
  494. {
  495. D3DVALUE d = ComputeDistance(pv, *(D3DVECTOR*)in);
  496. FOG_VERTEX(&pv->lighting, d);
  497. }
  498. if (outVID & D3DFVF_DIFFUSE)
  499. *pOut++ = pv->lighting.outDiffuse;
  500. if (outVID & D3DFVF_SPECULAR)
  501. *pOut++ = pv->lighting.outSpecular;
  502. // Fill zeros for non-FVF device
  503. if (bNoFVFandNoTexture)
  504. {
  505. *(D3DVALUE*)pOut++ = 0;
  506. *(D3DVALUE*)pOut = 0;
  507. }
  508. else
  509. for (k=0; k < nTex; k++)
  510. {
  511. *(D3DVALUE*)pOut++ = *inTexture[k];
  512. *(D3DVALUE*)pOut++ = *(inTexture[k] + 1);
  513. }
  514. }
  515. else
  516. {
  517. if (pv->dwDeviceFlags & D3DDEV_GUARDBAND)
  518. {
  519. D3DVALUE xnew = x * pv->vcache.gb11 + we * pv->vcache.gb41;
  520. D3DVALUE ynew = y * pv->vcache.gb22 + we * pv->vcache.gb42;
  521. D3DVALUE xx = we - xnew;
  522. D3DVALUE yy = we - ynew;
  523. clip |= ((ASINT32(xnew) & 0x80000000) >> (32-D3DCLIPGB_LEFTBIT)) |
  524. ((ASINT32(ynew) & 0x80000000) >> (32-D3DCLIPGB_BOTTOMBIT)) |
  525. ((ASINT32(xx) & 0x80000000) >> (32-D3DCLIPGB_RIGHTBIT)) |
  526. ((ASINT32(yy) & 0x80000000) >> (32-D3DCLIPGB_TOPBIT));
  527. }
  528. clip_intersection &= clip;
  529. clip_union |= clip;
  530. out->sx = x;
  531. out->sy = y;
  532. out->sz = z;
  533. out->rhw = we;
  534. }
  535. if (!(flags & D3DDP_DONOTCLIP))
  536. *hout++ = (D3DFE_CLIPCODE)clip;
  537. NEXT(in, pv->position.dwStride, D3DVECTOR);
  538. NEXT(inNormal, pv->normal.dwStride, D3DVECTOR);
  539. NEXT(inDiffuse, pv->diffuse.dwStride, DWORD);
  540. NEXT(inSpecular, pv->specular.dwStride, DWORD);
  541. {
  542. int j;
  543. for (j=0; j < nTex; j++)
  544. NEXT(inTexture[j], pv->textures[j].dwStride, D3DVALUE);
  545. }
  546. NEXT(out, out_size, D3DTLVERTEX);
  547. }
  548. if (!(flags & D3DDP_DONOTCLIP) && !clip_intersection && clip_union)
  549. { // We have to light all clipped vertices
  550. int n;
  551. D3DVECTOR *in = (D3DVECTOR*)pv->position.lpvData;
  552. D3DTLVERTEX *out = (D3DTLVERTEX*)pv->lpvOut;
  553. D3DVECTOR *inNormal;
  554. DWORD *inDiffuse;
  555. DWORD *inSpecular;
  556. D3DVALUE *inTexture[8];
  557. D3DFE_CLIPCODE *hout = pv->lpClipFlags;
  558. in = (D3DVECTOR*)pv->position.lpvData;
  559. inNormal = (D3DVECTOR*)pv->normal.lpvData;
  560. inDiffuse = (DWORD*)pv->diffuse.lpvData;
  561. inSpecular = (DWORD*)pv->specular.lpvData;
  562. for (i=0; i < nTex; i++)
  563. inTexture[i] = (D3DVALUE*)pv->textures[i].lpvData;
  564. for (n = count; n ; n--)
  565. {
  566. int j;
  567. if (*hout)
  568. {
  569. DWORD *pOut = (DWORD*)((char*)out + 4*sizeof(D3DVALUE));
  570. int k;
  571. if (pv->dwDeviceFlags & D3DDEV_GUARDBAND &&
  572. (*hout & ~__D3DCLIP_INGUARDBAND) == 0)
  573. { // This vertex is inside the guard band. We have to compute
  574. // screen coordinates for it
  575. D3DVALUE w = D3DVAL(1)/out->rhw;
  576. if (!(flags & D3DDP_DONOTUPDATEEXTENTS))
  577. {
  578. D3DVALUE x = out->sx * w * pv->vcache.scaleX + pv->vcache.offsetX;
  579. D3DVALUE y = out->sy * w * pv->vcache.scaleY + pv->vcache.offsetY;
  580. if (x < minx) minx = x;
  581. if (x > maxx) maxx = x;
  582. if (y < miny) miny = y;
  583. if (y > maxy) maxy = y;
  584. out->sx = x;
  585. out->sy = y;
  586. }
  587. else
  588. {
  589. out->sx = out->sx * w * pv->vcache.scaleX + pv->vcache.offsetX;
  590. out->sy = out->sy * w * pv->vcache.scaleY + pv->vcache.offsetY;
  591. }
  592. out->sz *= w;
  593. out->rhw = w;
  594. }
  595. if (flags & D3DPV_LIGHTING)
  596. {
  597. le.dvPosition = *in;
  598. le.dvNormal = *inNormal;
  599. if (pv->dwFlags & D3DPV_COLORVERTEX)
  600. {
  601. pv->lighting.alpha = *inDiffuse & 0xFF000000;
  602. MakeColor(&pv->lighting.vertexDiffuse, *inDiffuse);
  603. }
  604. if (pv->dwFlags & D3DPV_COLORVERTEXS)
  605. {
  606. MakeColor(&pv->lighting.vertexSpecular, *inSpecular);
  607. }
  608. LIGHT_VERTEX(pv, &le);
  609. }
  610. else
  611. if (inVID & (D3DFVF_DIFFUSE | D3DFVF_SPECULAR))
  612. {
  613. if (inVID & D3DFVF_DIFFUSE)
  614. pv->lighting.outDiffuse = *inDiffuse;
  615. if (inVID & D3DFVF_SPECULAR)
  616. pv->lighting.outSpecular = *inSpecular;
  617. }
  618. if (flags & D3DPV_FOG)
  619. {
  620. D3DVALUE d = ComputeDistance(pv, *(D3DVECTOR*)in);
  621. FOG_VERTEX(&pv->lighting, d);
  622. }
  623. if (outVID & D3DFVF_DIFFUSE)
  624. *pOut++ = pv->lighting.outDiffuse;
  625. if (outVID & D3DFVF_SPECULAR)
  626. *pOut++ = pv->lighting.outSpecular;
  627. if (bNoFVFandNoTexture)
  628. {
  629. *(D3DVALUE*)pOut++ = 0;
  630. *(D3DVALUE*)pOut = 0;
  631. }
  632. else
  633. for (k=0; k < nTex; k++)
  634. {
  635. *(D3DVALUE*)pOut++ = *inTexture[k];
  636. *(D3DVALUE*)pOut++ = *(inTexture[k] + 1);
  637. }
  638. }
  639. NEXT(in, pv->position.dwStride, D3DVECTOR);
  640. NEXT(inNormal, pv->normal.dwStride, D3DVECTOR);
  641. NEXT(inDiffuse, pv->diffuse.dwStride, DWORD);
  642. NEXT(inSpecular, pv->specular.dwStride, DWORD);
  643. for (j=0; j < nTex; j++)
  644. NEXT(inTexture[j], pv->textures[j].dwStride, D3DVALUE);
  645. NEXT(out, out_size, D3DTLVERTEX);
  646. hout++;
  647. }
  648. }
  649. if (!(flags & D3DDP_DONOTUPDATEEXTENTS))
  650. {
  651. /*
  652. * extend to cover lines. XXX
  653. */
  654. maxx += pv->dvExtentsAdjust;
  655. maxy += pv->dvExtentsAdjust;
  656. minx -= pv->dvExtentsAdjust;
  657. miny -= pv->dvExtentsAdjust;
  658. /* Clamp to viewport */
  659. if (minx < pv->vcache.minX)
  660. minx = pv->vcache.minX;
  661. if (miny < pv->vcache.minY)
  662. miny = pv->vcache.minY;
  663. if (maxx > pv->vcache.maxX)
  664. maxx = pv->vcache.maxX;
  665. if (maxy > pv->vcache.maxY)
  666. maxy = pv->vcache.maxY;
  667. pv->rExtents.x1 = minx;
  668. pv->rExtents.y1 = miny;
  669. pv->rExtents.x2 = maxx;
  670. pv->rExtents.y2 = maxy;
  671. }
  672. if (!(flags & D3DDP_DONOTCLIP))
  673. {
  674. pv->dwClipIntersection = clip_intersection;
  675. pv->dwClipUnion = clip_union;
  676. }
  677. else
  678. {
  679. pv->dwClipIntersection = 0;
  680. pv->dwClipUnion = 0;
  681. }
  682. return 0;
  683. }
  684. //--------------------------------------------------------------------------
  685. // Transform vertices, generate clip codes, apply light and fog.
  686. // General unoptimized case
  687. //
  688. // This function is called for legacy vertices:
  689. // D3DFVF_VERTEX or D3DFVF_LVERTEX as input
  690. // D3DFVF_TLVERTEX as ouput
  691. // The following fields from pv are used:
  692. // dwFlags
  693. // dwNumVertices
  694. // position.lpvData
  695. // lpvOut
  696. // lpClipFlags
  697. // nTexCoord
  698. // Returns:
  699. // returns dwClipIntersection or 0 (if D3DDP_DONOTCLIP is set)
  700. // Side effects:
  701. // dwClipUnion, dwClipIntersection are set only if D3DDP_DONOTCLIP is not set
  702. // rExtents is updated if D3DDP_DONOTUPDATEEXTENTS is not set
  703. //
  704. #undef DPF_MODNAME
  705. #define DPF_MODNAME "ProcessVerticesLegacy"
  706. DWORD ProcessVerticesLegacy(LPD3DFE_PROCESSVERTICES pv)
  707. {
  708. const DWORD in_size = sizeof(D3DVERTEX);
  709. const DWORD out_size = sizeof(D3DVERTEX);
  710. D3DVERTEX *in = (LPD3DVERTEX)pv->position.lpvData;
  711. D3DTLVERTEX *out =(LPD3DTLVERTEX)pv->lpvOut;
  712. int i;
  713. DWORD flags = pv->dwFlags;
  714. D3DFE_CLIPCODE *hout = pv->lpClipFlags;
  715. int clip_intersection = ~0;
  716. int clip_union = 0;
  717. D3DVALUE minx, maxx, miny, maxy;
  718. if (!(flags & D3DDP_DONOTUPDATEEXTENTS))
  719. {
  720. minx = pv->rExtents.x1;
  721. miny = pv->rExtents.y1;
  722. maxx = pv->rExtents.x2;
  723. maxy = pv->rExtents.y2;
  724. }
  725. for (i = pv->dwNumVertices; i; i--)
  726. {
  727. int clip;
  728. float x, y, z, w, we;
  729. x = in->x*pv->mCTM._11 + in->y*pv->mCTM._21 +
  730. in->z*pv->mCTM._31 + pv->mCTM._41;
  731. y = in->x*pv->mCTM._12 + in->y*pv->mCTM._22 +
  732. in->z*pv->mCTM._32 + pv->mCTM._42;
  733. z = in->x*pv->mCTM._13 + in->y*pv->mCTM._23 +
  734. in->z*pv->mCTM._33 + pv->mCTM._43;
  735. we= in->x*pv->mCTM._14 + in->y*pv->mCTM._24 +
  736. in->z*pv->mCTM._34 + pv->mCTM._44;
  737. if (!(flags & D3DDP_DONOTCLIP))
  738. {
  739. D3DVALUE xx = we - x;
  740. D3DVALUE yy = we - y;
  741. D3DVALUE zz = we - z;
  742. clip = ((ASINT32(x) & 0x80000000) >> (32-D3DCLIP_LEFTBIT)) |
  743. ((ASINT32(y) & 0x80000000) >> (32-D3DCLIP_BOTTOMBIT)) |
  744. ((ASINT32(z) & 0x80000000) >> (32-D3DCLIP_FRONTBIT)) |
  745. ((ASINT32(xx) & 0x80000000) >> (32-D3DCLIP_RIGHTBIT)) |
  746. ((ASINT32(yy) & 0x80000000) >> (32-D3DCLIP_TOPBIT)) |
  747. ((ASINT32(zz) & 0x80000000) >> (32-D3DCLIP_BACKBIT));
  748. }
  749. else
  750. clip = 0;
  751. if (clip == 0)
  752. {
  753. // We have to check this only for DONOTCLIP case, because otherwise
  754. // "clip" is not zero, if we is zero.
  755. if (!FLOAT_EQZ(we))
  756. w = D3DVAL(1)/we;
  757. else
  758. w = __HUGE_PWR2;
  759. clip_intersection = 0;
  760. if (!(flags & D3DDP_DONOTUPDATEEXTENTS))
  761. {
  762. x = x * w * pv->vcache.scaleX + pv->vcache.offsetX;
  763. y = y * w * pv->vcache.scaleY + pv->vcache.offsetY;
  764. if (x < minx) minx = x;
  765. if (x > maxx) maxx = x;
  766. if (y < miny) miny = y;
  767. if (y > maxy) maxy = y;
  768. }
  769. else
  770. {
  771. x = x * w * pv->vcache.scaleX + pv->vcache.offsetX;
  772. y = y * w * pv->vcache.scaleY + pv->vcache.offsetY;
  773. }
  774. out->sx = x;
  775. out->sy = y;
  776. out->sz = z*w;
  777. out->rhw = w;
  778. // In ramp mode pv->lighting.diffuse.r and pv->lighting.specular.r
  779. // are used to store trhe result of lighting.
  780. // Otherwise pv->lighting.outDiffuse and pv->lighting.outSpecular
  781. // are used
  782. if (flags & D3DPV_LIGHTING)
  783. {
  784. if (pv->dwDeviceFlags & D3DDEV_RAMP)
  785. LIGHT_VERTEX_RAMP(pv, in);
  786. else
  787. LIGHT_VERTEX(pv, in);
  788. }
  789. else
  790. if (pv->dwVIDIn & (D3DFVF_DIFFUSE | D3DFVF_SPECULAR))
  791. {
  792. if (pv->dwDeviceFlags & D3DDEV_RAMP)
  793. {
  794. pv->lighting.alpha = ((D3DLVERTEX*)in)->color & 0xFF000000;
  795. pv->lighting.diffuse.r = RGB_GETBLUE(((D3DLVERTEX*)in)->color)*__ONE_OVER_255;
  796. pv->lighting.specular.r = RGB_GETBLUE(((D3DLVERTEX*)in)->specular)*__ONE_OVER_255;
  797. }
  798. else
  799. {
  800. pv->lighting.outDiffuse = ((D3DLVERTEX*)in)->color;
  801. pv->lighting.outSpecular = ((D3DLVERTEX*)in)->specular;
  802. }
  803. }
  804. else
  805. {
  806. if (pv->dwDeviceFlags & D3DDEV_RAMP)
  807. {
  808. pv->lighting.alpha = 0xFF000000;
  809. pv->lighting.diffuse.r = D3DVAL(0);
  810. pv->lighting.specular.r = D3DVAL(0);
  811. }
  812. else
  813. {
  814. pv->lighting.outDiffuse = __DEFAULT_DIFFUSE;
  815. pv->lighting.outSpecular = __DEFAULT_SPECULAR;
  816. }
  817. }
  818. if (flags & D3DPV_FOG)
  819. {
  820. D3DVALUE d;
  821. if (pv->dwDeviceFlags & D3DDEV_PREDX6DEVICE)
  822. d = we;
  823. else
  824. d = ComputeDistance(pv, *(D3DVECTOR*)in);
  825. if (pv->dwDeviceFlags & D3DDEV_RAMP)
  826. FOG_VERTEX_RAMP(&pv->lighting, d);
  827. else
  828. FOG_VERTEX(&pv->lighting, d);
  829. }
  830. if (pv->dwDeviceFlags & D3DDEV_RAMP)
  831. {
  832. MAKE_VERTEX_COLOR_RAMP(pv, out);
  833. }
  834. else
  835. {
  836. out->color = pv->lighting.outDiffuse;
  837. out->specular = pv->lighting.outSpecular;
  838. }
  839. out->tu = in->tu;
  840. out->tv = in->tv;
  841. }
  842. else
  843. {
  844. if (pv->dwDeviceFlags & D3DDEV_GUARDBAND)
  845. {
  846. D3DVALUE xnew = x * pv->vcache.gb11 + we * pv->vcache.gb41;
  847. D3DVALUE ynew = y * pv->vcache.gb22 + we * pv->vcache.gb42;
  848. D3DVALUE xx = we - xnew;
  849. D3DVALUE yy = we - ynew;
  850. clip |= ((ASINT32(xnew) & 0x80000000) >> (32-D3DCLIPGB_LEFTBIT)) |
  851. ((ASINT32(ynew) & 0x80000000) >> (32-D3DCLIPGB_BOTTOMBIT)) |
  852. ((ASINT32(xx) & 0x80000000) >> (32-D3DCLIPGB_RIGHTBIT)) |
  853. ((ASINT32(yy) & 0x80000000) >> (32-D3DCLIPGB_TOPBIT));
  854. }
  855. clip_intersection &= clip;
  856. clip_union |= clip;
  857. out->sx = x;
  858. out->sy = y;
  859. out->sz = z;
  860. out->rhw = we;
  861. }
  862. if (!(flags & D3DDP_DONOTCLIP))
  863. *hout++ = (D3DFE_CLIPCODE)clip;
  864. in = (D3DVERTEX*) ((char*) in + in_size);
  865. out = (D3DTLVERTEX*) ((char*) out + out_size);
  866. }
  867. if (!(flags & D3DDP_DONOTCLIP) && !clip_intersection && clip_union)
  868. { // There are vertices outside the screen as well as inside.
  869. // We have to compute lighting for vertices that are outside the screen
  870. int n;
  871. D3DVERTEX* in = (LPD3DVERTEX)pv->position.lpvData;
  872. D3DTLVERTEX *out = (LPD3DTLVERTEX)pv->lpvOut;
  873. D3DFE_CLIPCODE *hout = pv->lpClipFlags;
  874. for (n = pv->dwNumVertices; n ; n--)
  875. {
  876. if (*hout)
  877. {
  878. D3DVALUE rhw = out->rhw; // Save it for fog
  879. if (pv->dwDeviceFlags & D3DDEV_GUARDBAND &&
  880. (*hout & ~__D3DCLIP_INGUARDBAND) == 0)
  881. { // This vertex is inside the guard band. We have to compute
  882. // screen coordinates for it
  883. D3DVALUE w = D3DVAL(1)/out->rhw;
  884. if (!(flags & D3DDP_DONOTUPDATEEXTENTS))
  885. {
  886. D3DVALUE x = out->sx * w * pv->vcache.scaleX + pv->vcache.offsetX;
  887. D3DVALUE y = out->sy * w * pv->vcache.scaleY + pv->vcache.offsetY;
  888. if (x < minx) minx = x;
  889. if (x > maxx) maxx = x;
  890. if (y < miny) miny = y;
  891. if (y > maxy) maxy = y;
  892. out->sx = x;
  893. out->sy = y;
  894. }
  895. else
  896. {
  897. out->sx = out->sx * w * pv->vcache.scaleX + pv->vcache.offsetX;
  898. out->sy = out->sy * w * pv->vcache.scaleY + pv->vcache.offsetY;
  899. }
  900. out->sz *= w;
  901. out->rhw = w;
  902. }
  903. if (flags & D3DPV_LIGHTING)
  904. {
  905. if (pv->dwDeviceFlags & D3DDEV_RAMP)
  906. LIGHT_VERTEX_RAMP(pv, in);
  907. else
  908. LIGHT_VERTEX(pv, in);
  909. }
  910. else
  911. if (pv->dwVIDIn & (D3DFVF_DIFFUSE | D3DFVF_SPECULAR))
  912. {
  913. if (pv->dwDeviceFlags & D3DDEV_RAMP)
  914. {
  915. pv->lighting.alpha = ((D3DLVERTEX*)in)->color & 0xFF000000;
  916. pv->lighting.diffuse.r = RGB_GETBLUE(((D3DLVERTEX*)in)->color)*__ONE_OVER_255;
  917. pv->lighting.specular.r = RGB_GETBLUE(((D3DLVERTEX*)in)->specular)*__ONE_OVER_255;
  918. }
  919. else
  920. {
  921. pv->lighting.outDiffuse = ((D3DLVERTEX*)in)->color;
  922. pv->lighting.outSpecular = ((D3DLVERTEX*)in)->specular;
  923. }
  924. }
  925. else
  926. {
  927. if (pv->dwDeviceFlags & D3DDEV_RAMP)
  928. {
  929. pv->lighting.alpha = 0xFF000000;
  930. pv->lighting.diffuse.r = D3DVAL(0);
  931. pv->lighting.specular.r = D3DVAL(0);
  932. }
  933. else
  934. {
  935. pv->lighting.outDiffuse = __DEFAULT_DIFFUSE;
  936. pv->lighting.outSpecular = __DEFAULT_SPECULAR;
  937. }
  938. }
  939. if (flags & D3DPV_FOG)
  940. {
  941. D3DVALUE d;
  942. if (pv->dwDeviceFlags & D3DDEV_PREDX6DEVICE)
  943. d = rhw;
  944. else
  945. d = ComputeDistance(pv, *(D3DVECTOR*)in);
  946. if (pv->dwDeviceFlags & D3DDEV_RAMP)
  947. FOG_VERTEX_RAMP(&pv->lighting, d);
  948. else
  949. FOG_VERTEX(&pv->lighting, d);
  950. }
  951. if (pv->dwDeviceFlags & D3DDEV_RAMP)
  952. {
  953. MAKE_VERTEX_COLOR_RAMP(pv, out);
  954. }
  955. else
  956. {
  957. out->color = pv->lighting.outDiffuse;
  958. out->specular = pv->lighting.outSpecular;
  959. }
  960. out->tu = in->tu;
  961. out->tv = in->tv;
  962. }
  963. in = (D3DVERTEX*) ((char*) in + in_size);
  964. out = (D3DTLVERTEX*) ((char*) out + out_size);
  965. hout++;
  966. }
  967. }
  968. if (!(flags & D3DDP_DONOTUPDATEEXTENTS))
  969. {
  970. //extend to cover lines. XXX
  971. maxx += pv->dvExtentsAdjust;
  972. maxy += pv->dvExtentsAdjust;
  973. minx -= pv->dvExtentsAdjust;
  974. miny -= pv->dvExtentsAdjust;
  975. // Clamp to viewport
  976. // Clamp for legacy apps
  977. if (minx < pv->vcache.minX || miny < pv->vcache.minY ||
  978. maxx > pv->vcache.maxX || maxy > pv->vcache.maxY)
  979. {
  980. // Clamp to viewport
  981. if (minx < pv->vcache.minX)
  982. minx = pv->vcache.minX;
  983. if (miny < pv->vcache.minY)
  984. miny = pv->vcache.minY;
  985. if (maxx > pv->vcache.maxX)
  986. maxx = pv->vcache.maxX;
  987. if (maxy > pv->vcache.maxY)
  988. maxy = pv->vcache.maxY;
  989. if (flags & D3DDP_DONOTCLIP)
  990. {
  991. if(pv->dwDeviceFlags & D3DDEV_PREDX5DEVICE)
  992. { // Clamp vertices
  993. int i;
  994. D3D_WARN(4, "Old semantics: Clamping Vertices");
  995. for (i = pv->dwNumVertices,
  996. out = (LPD3DTLVERTEX)pv->lpvOut; i; i--)
  997. {
  998. if (out->sx < pv->vcache.minX) out->sx = pv->vcache.minX;
  999. if (out->sx > pv->vcache.maxX) out->sx = pv->vcache.maxX;
  1000. if (out->sy < pv->vcache.minY) out->sy = pv->vcache.minY;
  1001. if (out->sy > pv->vcache.maxY) out->sy = pv->vcache.maxY;
  1002. out = (D3DTLVERTEX*) ((char*) out + out_size);
  1003. }
  1004. }
  1005. }
  1006. }
  1007. pv->rExtents.x1 = minx;
  1008. pv->rExtents.y1 = miny;
  1009. pv->rExtents.x2 = maxx;
  1010. pv->rExtents.y2 = maxy;
  1011. }
  1012. if (!(flags & D3DDP_DONOTCLIP))
  1013. {
  1014. pv->dwClipIntersection = clip_intersection;
  1015. pv->dwClipUnion = clip_union;
  1016. return clip_intersection;
  1017. }
  1018. return 0;
  1019. }
  1020. DWORD D3DFE_PVFUNCS::ProcessVertices(LPD3DFE_PROCESSVERTICES pv)
  1021. {
  1022. CD3DFPstate D3DFPstate; // Sets optimal FPU state for D3D.
  1023. if (!(pv->dwFlags & D3DPV_STRIDE))
  1024. {
  1025. if ((pv->dwVIDIn == D3DFVF_VERTEX ||
  1026. pv->dwVIDIn == D3DFVF_LVERTEX) &&
  1027. pv->dwVIDOut == D3DFVF_TLVERTEX)
  1028. {
  1029. ProcessVerticesLegacy(pv);
  1030. }
  1031. else
  1032. {
  1033. ProcessVerticesFVF(pv);
  1034. }
  1035. }
  1036. else
  1037. {
  1038. ProcessVerticesFVFS(pv);
  1039. }
  1040. return pv->dwClipIntersection;
  1041. }
  1042. HRESULT D3DFE_PVFUNCS::ProcessPrimitive(LPD3DFE_PROCESSVERTICES pv)
  1043. {
  1044. ProcessVertices(pv);
  1045. if (pv->dwClipIntersection)
  1046. {
  1047. // all vertices were offscreen
  1048. return D3D_OK;
  1049. }
  1050. pv->dwFlags |= D3DPV_WITHINPRIMITIVE;
  1051. // This should not be required as we should be able to change
  1052. // the parameter of DoDrawPrimtive and all it's children to pv
  1053. return (DoDrawPrimitive(pv));
  1054. }
  1055. HRESULT D3DFE_PVFUNCS::ProcessIndexedPrimitive(LPD3DFE_PROCESSVERTICES pv)
  1056. {
  1057. ProcessVertices(pv);
  1058. if (pv->dwClipIntersection)
  1059. {
  1060. // all vertices were offscreen
  1061. return D3D_OK;
  1062. }
  1063. pv->dwFlags |= D3DPV_WITHINPRIMITIVE;
  1064. // This should not be required as we should be able to change
  1065. // the parameter of DoDrawIndexedPrimtive and all it's children to pv
  1066. return (DoDrawIndexedPrimitive(pv));
  1067. }