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.

583 lines
24 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1997 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: d3dfe.hpp
  6. * Content: Direct3D internal include file
  7. * for geometry pipeline implementations
  8. *
  9. ***************************************************************************/
  10. #ifndef _D3DFE_H
  11. // this is not available for alpha or IA64
  12. #ifndef LONG_MAX
  13. #define LONG_MAX 2147483647L /* maximum (signed) long value */
  14. #endif
  15. //--------------------------------------------------------------------
  16. // Base definitions
  17. //
  18. // Default color values that should be used when ther is no lighting and
  19. // color in vertices provided
  20. const DWORD __DEFAULT_DIFFUSE = 0xFFFFFFFF;
  21. const DWORD __DEFAULT_SPECULAR = 0;
  22. typedef WORD D3DFE_CLIPCODE;
  23. //---------------------------------------------------------------------
  24. typedef struct _RECTV
  25. {
  26. union
  27. {
  28. D3DVALUE x1;
  29. D3DVALUE dvX1;
  30. };
  31. union
  32. {
  33. D3DVALUE y1;
  34. D3DVALUE dvY1;
  35. };
  36. union
  37. {
  38. D3DVALUE x2;
  39. D3DVALUE dvX2;
  40. };
  41. union
  42. {
  43. D3DVALUE y2;
  44. D3DVALUE dvY2;
  45. };
  46. } D3DRECTV, *LPD3DRECTV;
  47. //---------------------------------------------------------------------
  48. /*
  49. * Transform defines
  50. */
  51. /*
  52. * Internal version of D3DTRANSFORMDATA
  53. * The difference is that drExtent is D3DRECTV instead of D3DRECT
  54. */
  55. typedef struct _D3DTRANSFORMDATAI
  56. {
  57. DWORD dwSize;
  58. LPVOID lpIn; /* Input vertices */
  59. DWORD dwInSize; /* Stride of input vertices */
  60. LPVOID lpOut; /* Output vertices */
  61. DWORD dwOutSize; /* Stride of output vertices */
  62. LPD3DHVERTEX lpHOut; /* Output homogeneous vertices */
  63. DWORD dwClip; /* Clipping hint */
  64. DWORD dwClipIntersection;
  65. DWORD dwClipUnion; /* Union of all clip flags */
  66. D3DRECTV drExtent; /* Extent of transformed vertices */
  67. } D3DTRANSFORMDATAI, *LPD3DTRANSFORMDATAI;
  68. //---------------------------------------------------------------------
  69. typedef enum _D3MATRIXTYPEI
  70. {
  71. D3DIMatrixIdentity,
  72. D3DIMatrixTranslate,
  73. D3DIMatrixRotateTranslate,
  74. D3DIMatrixAffine,
  75. D3DIMatrixGeneral
  76. } D3DMATRIXTYPEI;
  77. //---------------------------------------------------------------------
  78. // "link" member should be the last, because we copy the structure using
  79. // offsetof(D3DMATRIXI, link)
  80. //
  81. typedef struct _D3DMATRIXI
  82. {
  83. D3DVALUE _11, _12, _13, _14;
  84. D3DVALUE _21, _22, _23, _24;
  85. D3DVALUE _31, _32, _33, _34;
  86. D3DVALUE _41, _42, _43, _44;
  87. D3DMATRIXTYPEI type;
  88. LIST_MEMBER(_D3DMATRIXI) link;
  89. } D3DMATRIXI, *LPD3DMATRIXI;
  90. //---------------------------------------------------------------------
  91. struct _D3DFE_LIGHTING;
  92. typedef struct _D3DFE_LIGHTING D3DFE_LIGHTING;
  93. struct _D3DI_LIGHT;
  94. typedef struct _D3DI_LIGHT D3DI_LIGHT;
  95. class D3DFE_PROCESSVERTICES;
  96. typedef class D3DFE_PROCESSVERTICES* LPD3DFE_PROCESSVERTICES;
  97. extern "C"
  98. {
  99. typedef void (*LIGHT_VERTEX_FUNC)(LPD3DFE_PROCESSVERTICES pv,
  100. D3DI_LIGHT *light,
  101. D3DLIGHTINGELEMENT *in);
  102. }
  103. //---------------------------------------------------------------------
  104. /*
  105. * Lighting defines
  106. */
  107. typedef struct _SpecularTable
  108. {
  109. LIST_MEMBER(_SpecularTable) list;
  110. float power; /* shininess power */
  111. float table[260]; /* space for overflows */
  112. } SpecularTable;
  113. typedef struct {D3DVALUE r,g,b;} D3DFE_COLOR;
  114. //---------------------------------------------------------------------
  115. // Internal version of lightdata and constants for flags
  116. //
  117. #define D3DLIGHTI_ATT0_IS_NONZERO (0x00010000)
  118. #define D3DLIGHTI_ATT1_IS_NONZERO (0x00020000)
  119. #define D3DLIGHTI_ATT2_IS_NONZERO (0x00040000)
  120. #define D3DLIGHTI_LINEAR_FALLOFF (0x00080000)
  121. #define D3DLIGHTI_UNIT_SCALE (0x00100000)
  122. #define D3DLIGHTI_LIGHT_AT_EYE (0x00200000)
  123. #define D3DLIGHTI_COMPUTE_SPECULAR (0x00400000)
  124. //--------------------------------------------------------------------
  125. // Members of this structure should be aligned as stated
  126. typedef struct _D3DI_LIGHT
  127. {
  128. // Should be QWORD aligned
  129. D3DVECTOR model_position;
  130. D3DLIGHTTYPE type;
  131. // Should be QWORD aligned
  132. D3DVECTOR model_direction;
  133. DWORD version; // matches number on D3DLIGHT struct
  134. // Should be QWORD aligned
  135. D3DVECTOR model_eye; // direction from eye in model space
  136. DWORD flags;
  137. // Should be QWORD aligned
  138. D3DVECTOR model_scale; // model scale for proper range computations
  139. D3DVALUE falloff;
  140. // Should be QWORD aligned. R,G,B should be adjacent
  141. D3DVALUE local_diffR; // Material diffuse times light color
  142. D3DVALUE local_diffG;
  143. D3DVALUE local_diffB;
  144. BOOL valid;
  145. // Should be QWORD aligned. R,G,B should be adjacent
  146. D3DVALUE local_specR; // Material specular times light color
  147. D3DVALUE local_specG;
  148. D3DVALUE local_specB;
  149. D3DVALUE inv_theta_minus_phi;
  150. // Should be QWORD aligned
  151. D3DVECTOR halfway;
  152. struct _D3DI_LIGHT *next; // Next in the active light list
  153. // Should be QWORD aligned
  154. D3DVALUE red, green, blue, shade;
  155. LIGHT_VERTEX_FUNC lightVertexFunc; // Function to light a D3DVERTEX
  156. D3DVALUE range_squared;
  157. D3DVALUE attenuation0;
  158. D3DVALUE attenuation1;
  159. D3DVALUE attenuation2;
  160. D3DVALUE cos_theta_by_2;
  161. D3DVALUE cos_phi_by_2;
  162. D3DVECTOR position;
  163. D3DVECTOR direction;
  164. D3DVALUE range;
  165. } D3DI_LIGHT, *LPD3DI_LIGHT;
  166. //---------------------------------------------------------------------
  167. // Members of this structure should be aligned as stated
  168. //
  169. typedef struct _D3DFE_LIGHTING
  170. {
  171. // Temporary data used when computing lighting
  172. // Should be QWORD aligned
  173. D3DFE_COLOR diffuse;
  174. int alpha; // Alpha to use for output vertex color
  175. // (could be overriden by vertex difuse
  176. // color) (0-255) shifted left by 24 bits
  177. // Should be QWORD aligned
  178. D3DFE_COLOR diffuse0; // Ca*Cma + Cme
  179. float *currentSpecTable;
  180. // Should be QWORD aligned
  181. D3DFE_COLOR specular;
  182. DWORD outDiffuse; // Result of lighting
  183. // Should be QWORD aligned
  184. D3DFE_COLOR vertexDiffuse; // Provided with a vertex
  185. DWORD outSpecular; // Result of lighting
  186. // Should be QWORD aligned
  187. D3DFE_COLOR vertexSpecular; // Provided with a vertex
  188. BOOL specularComputed;
  189. // End of temporary data
  190. D3DI_LIGHT *activeLights;
  191. D3DMATERIAL material;
  192. D3DMATERIALHANDLE hMat;
  193. D3DVALUE ambient_red; // Scaled to 0 - 255
  194. D3DVALUE ambient_green; // Scaled to 0 - 255
  195. D3DVALUE ambient_blue; // Scaled to 0 - 255
  196. int fog_mode;
  197. D3DVALUE fog_density;
  198. D3DVALUE fog_start;
  199. D3DVALUE fog_end;
  200. D3DVALUE fog_factor; // 255 / (fog_end - fog_start)
  201. D3DVALUE fog_factor_ramp;// 1 / (fog_end - fog_start)
  202. D3DVALUE specThreshold; // If a dot product less than this value,
  203. // specular factor is zero
  204. D3DCOLORMODEL color_model;
  205. DWORD ambient_save; // Original unscaled color
  206. int materialAlpha; // Current material alpha (0-255) shifted
  207. // left by 24 bits
  208. } D3DFE_LIGHTING;
  209. //---------------------------------------------------------------------
  210. // Some data precomputed for a current viewport
  211. // ATTENTION: If you want to add or re-arrange data, contact IOURIT or ANUJG
  212. //
  213. typedef struct _D3DFE_VIEWPORTCACHE
  214. {
  215. // Coefficients to compute screen coordinates from normalized window
  216. // coordinates
  217. D3DVALUE scaleX; // dvWidth/2
  218. D3DVALUE scaleY; // dvHeight/2
  219. D3DVALUE offsetX; // dvX + scaleX
  220. D3DVALUE offsetY; // dvY + scaleY
  221. // Min and max window values with gaurd band in pixels
  222. D3DVALUE minXgb;
  223. D3DVALUE minYgb;
  224. D3DVALUE maxXgb;
  225. D3DVALUE maxYgb;
  226. // Min and max values for viewport window in pixels
  227. D3DVALUE minX; // offsetX - scaleX
  228. D3DVALUE minY; // offsetY - scaleY
  229. D3DVALUE maxX; // offsetX + scaleX
  230. D3DVALUE maxY; // offsetY + scaleY
  231. // Coefficients to transform a vertex to perform the guard band clipping
  232. // x*gb11 + w*gb41
  233. // y*gb22 + w*gb42
  234. //
  235. D3DVALUE gb11;
  236. D3DVALUE gb22;
  237. D3DVALUE gb41;
  238. D3DVALUE gb42;
  239. // Coefficients to apply clipping rules for the guard band clipping
  240. // They are used by clipping routins
  241. // w*Kgbx1 < x < w*Kgbx2
  242. // w*Kgby1 < y < w*Kgby2
  243. //
  244. D3DVALUE Kgbx1;
  245. D3DVALUE Kgby1;
  246. D3DVALUE Kgbx2;
  247. D3DVALUE Kgby2;
  248. D3DVALUE dvX; // dwX
  249. D3DVALUE dvY; // dwY
  250. D3DVALUE dvWidth; // dwWidth
  251. D3DVALUE dvHeight; // dwHeight
  252. // Coefficients to compute screen coordinates from normalized window
  253. // coordinates
  254. D3DVALUE scaleXi; // Inverse of scaleX
  255. D3DVALUE scaleYi; // Inverse of scaleY
  256. // Min and max values for viewport window in pixels (integer version)
  257. int minXi; // offsetX - scaleX
  258. int minYi; // offsetY - scaleY
  259. int maxXi; // offsetX + scaleX
  260. int maxYi; // offsetY + scaleY
  261. // Mclip matrix. mclip44=1. Other Mclip(i,j)=0
  262. D3DVALUE mclip11; // 2/dvClipWidth
  263. D3DVALUE mclip41; // -(1+2*dvClipX/dvClipWidth)
  264. D3DVALUE mclip22; // 2/dvClipHeight
  265. D3DVALUE mclip42; // (1-2*dvClipY/dvClipHeight)
  266. D3DVALUE mclip33; // 1/(dvMaxZ-dvMinZ)
  267. D3DVALUE mclip43; // -dvMinZ*mclip33
  268. // Inverse Mclip matrix. We need this matrix to transform vertices from clip
  269. // space to homogineous space (after Mproj). We need this when user calls
  270. // Transform Vertices. This matrix is computed only when it is needed.
  271. D3DVALUE imclip11;
  272. D3DVALUE imclip41;
  273. D3DVALUE imclip22;
  274. D3DVALUE imclip42;
  275. D3DVALUE imclip33;
  276. D3DVALUE imclip43;
  277. } D3DFE_VIEWPORTCACHE;
  278. //---------------------------------------------------------------------
  279. // Process vertices interface
  280. //
  281. // Bits for process vertices flags
  282. // 8 bits are reserved for Draw Primitive flags
  283. //
  284. // D3DPV_STRIDE D3DPV_SOA
  285. // 0 1 position.dwStride = number of vertices in SOA
  286. // 0 0 position.dwStride = contiguous vertex size
  287. // 1 0 vertex is not contiguous, all dwStride fields are used
  288. // 1 1 reserved
  289. // 1 1 reserved
  290. //
  291. const DWORD D3DPV_FOG = 1 << 8; // Need to apply fog
  292. const DWORD D3DPV_AFFINEMATRIX = 1 << 9; // Last matrix column is (0,0,1,x)
  293. const DWORD D3DPV_LIGHTING = 1 << 10; // Need to apply lighting
  294. const DWORD D3DPV_SOA = 1 << 12; // SOA structure is used
  295. const DWORD D3DPV_STRIDE = 1 << 13; // Strides are used
  296. const DWORD D3DPV_COLORVERTEX = 1 << 14; // Diffuse color vertex
  297. const DWORD D3DPV_COLORVERTEXS = 1 << 15; // Specular color vertex
  298. // These two flags should NOT be used. Use D3DDEV_.. instead
  299. const DWORD D3DPV_TRANSFORMDIRTY = 1 << 16; // Transform matrix has been changed
  300. const DWORD D3DPV_LIGHTSDIRTY = 1 << 17; // Lights have been changed
  301. const DWORD D3DPV_COMPUTESPECULAR= 1 << 18; // Specular highlights are enabled
  302. const DWORD D3DPV_RANGEBASEDFOG = 1 << 19; // Do range based fog
  303. const DWORD D3DPV_GOODPROJMATRIX = 1 << 20; // "Good" projection matrix (All
  304. // members except M11 M22 M33 M43
  305. // M34 are zero)
  306. const DWORD D3DPV_CLIPPERPRIM = 1 << 21; // This indicates that the primitive
  307. // was generated by clipping. This allows
  308. // DP2HAL to inline the primitive. Can
  309. // only by tri fan or line list.
  310. const DWORD D3DPV_RESERVED1 = 1 << 22;
  311. const DWORD D3DPV_RESERVED2 = 1 << 23;
  312. const DWORD D3DPV_RESERVED3 = 1 << 24;
  313. // This indicates that the primitive is non clipped, but we pretend that it is
  314. // clipped to generate DP2HAL inline primitive. Can only be set by tri fan.
  315. const DWORD D3DPV_NONCLIPPED = 1 << 25;
  316. // Propagated from dwFEFlags
  317. const DWORD D3DPV_FRUSTUMPLANES_DIRTY = 1 << 26;
  318. // Set if the geometry loop is called from VertexBuffer::ProcessVertices.
  319. // Processing is different because the output buffer FVF format is defined by
  320. // user, not by ComputeOutputFVF function.
  321. const DWORD D3DPV_VBCALL = 1 << 27;
  322. const DWORD D3DPV_RAMPSPECULAR = 1 << 28; // whether ramp map was made with specular
  323. const DWORD D3DPV_TLVCLIP = 1 << 29; // To mark whether we are doing TLVERTEX clipping or not
  324. // Bits for dwDeviceFlags
  325. //
  326. const DWORD D3DDEV_GUARDBAND = 1 << 1; // Use guard band clipping
  327. const DWORD D3DDEV_PREDX5DEVICE = 1 << 2; // Device version is older than DX5
  328. const DWORD D3DDEV_RAMP = 1 << 3; // Ramp mode is used
  329. const DWORD D3DDEV_FVF = 1 << 4; // FVF supported
  330. const DWORD D3DDEV_PREDX6DEVICE = 1 << 5; // Device version is older than DX6
  331. const DWORD D3DDEV_DONOTSTRIPELEMENTS = 1 << 6; // Copy of D3DFVFCAPS_DONOTSTRIPELEMENTS
  332. // These are bits in dwDeviceFlags that could be changed, but not
  333. // necessary per every primitive.
  334. // If D3DRENDERSTATE_TEXTUREHANDLE was set by API to not NULL
  335. const DWORD D3DDEV_LEGACYTEXTURE = 1 << 16;
  336. // These flags should be used instead of D3DPV_...
  337. const DWORD D3DDEV_TRANSFORMDIRTY = 1 << 17; // Transform matrix has been changed
  338. const DWORD D3DDEV_LIGHTSDIRTY = 1 << 18; // Lights have been changed
  339. //--------------------------------------------------------------------
  340. // Clipper defines
  341. //
  342. // Six standard clipping planes plus six user defined clipping planes.
  343. // See rl\d3d\d3d\d3dtypes.h.
  344. //
  345. #define MAX_CLIPPING_PLANES 12
  346. // Space for vertices generated/copied while clipping one triangle
  347. #define MAX_CLIP_VERTICES (( 2 * MAX_CLIPPING_PLANES ) + 3 )
  348. // 3 verts. -> 1 tri, 4 v -> 2 t, N vertices -> (N - 2) triangles
  349. #define MAX_CLIP_TRIANGLES ( MAX_CLIP_VERTICES - 2 )
  350. const DWORD MAX_FVF_TEXCOORD = 8;
  351. typedef struct _CLIP_TEXTURE
  352. {
  353. D3DVALUE u, v;
  354. } CLIP_TEXTURE;
  355. typedef struct _ClipVertex
  356. {
  357. D3DCOLOR color;
  358. D3DCOLOR specular;
  359. D3DVALUE sx;
  360. D3DVALUE sy;
  361. D3DVALUE sz;
  362. D3DVALUE hx;
  363. D3DVALUE hy;
  364. D3DVALUE hz;
  365. D3DVALUE hw;
  366. CLIP_TEXTURE tex[MAX_FVF_TEXCOORD];
  367. int clip;
  368. } ClipVertex;
  369. typedef struct _ClipTriangle
  370. {
  371. ClipVertex *v[3];
  372. unsigned short flags;
  373. } ClipTriangle;
  374. typedef struct _D3DI_CLIPSTATE
  375. {
  376. ClipVertex *clip_vbuf1[MAX_CLIP_VERTICES];
  377. ClipVertex *clip_vbuf2[MAX_CLIP_VERTICES];
  378. ClipVertex **current_vbuf; // clip_vbuf1 or clip_vbuf2
  379. ClipVertex clip_vertices[MAX_CLIP_VERTICES];
  380. CBufferDDS clipBuf; // Used for TL vertices, generated by the clipper
  381. CBufferDDS clipBufPrim; // Used for primitives, generated by the clipper
  382. // for execute buffers
  383. int clip_vertices_used;
  384. DWORD clip_color;
  385. DWORD clip_specular;
  386. LPDIRECTDRAWSURFACE lpDDExeBuf; // Current user execute buffer
  387. LPVOID lpvExeBufMem; // Current memory for user execute buffer
  388. } D3DI_CLIPSTATE, *LPD3DI_CLIPSTATE;
  389. //---------------------------------------------------------------------
  390. // Visible states, input and output data
  391. //
  392. class D3DFE_PROCESSVERTICES
  393. {
  394. public:
  395. // State
  396. DWORD dwRampBase; // Parameters to compute ramp color. They are
  397. D3DVALUE dvRampScale; // constant for a material.
  398. LPVOID lpvRampTexture;
  399. // Should be 32 bytes aligned
  400. D3DMATRIXI mCTM; // Current Transformation Matrix
  401. DWORD dwMaxTextureIndices; // Max number of texture coord sets
  402. // supported by driver
  403. // Should be QWORD aligned
  404. D3DFE_LIGHTING lighting; // Lighting state
  405. D3DVALUE dvExtentsAdjust; // Replicated here from device caps
  406. // Should be QWORD aligned
  407. D3DFE_VIEWPORTCACHE vcache; // Data, computed fromto viewport settings
  408. DWORD dwClipUnion; // OR of all vertex clip flags
  409. DWORD dwClipIntersection; // AND of all vertex clip flags
  410. union
  411. {
  412. DWORD dwTextureIndexToCopy; // Used for not FVF devices. Used by PSGP
  413. DWORD dwMaxUsedTextureIndex; // Used for FVF devices. PSGP do not use it.
  414. };
  415. // Current texture stage vector
  416. LPVOID *pD3DMappedTexI;
  417. D3DI_CLIPSTATE ClipperState; // State for triangle/line clipper
  418. union {
  419. D3DDP_PTRSTRIDE normal;
  420. DWORD dwSOAStartVertex;
  421. };
  422. D3DDP_PTRSTRIDE diffuse;
  423. D3DDP_PTRSTRIDE specular;
  424. // Cache line starts here
  425. // Location of the first vertex in the vertex buffer (DP2 DDI)
  426. // ATTENTION May be we can get rid of it?
  427. DWORD dwVertexBase;
  428. // Input
  429. DWORD dwDeviceFlags; // Flags that are constant per device
  430. // D3DPV_.. and primitive flags are combined
  431. LPVOID lpvOut; // Output pointer (output always packed)
  432. D3DFE_CLIPCODE* lpClipFlags; // Clip flags to output
  433. DWORD dwNumIndices; // 0 for non-indexed primitive
  434. LPWORD lpwIndices;
  435. union {
  436. D3DDP_PTRSTRIDE position; // dwStride should always be set !!!
  437. D3DDP_PTRSTRIDE SOA;
  438. };
  439. // Cache line starts here
  440. DWORD dwFlags; // Flags word describing what to do
  441. DWORD dwNumVertices; // Number of vertices to process
  442. DWORD dwNumPrimitives;
  443. D3DPRIMITIVETYPE primType;
  444. DWORD dwVIDIn; // Vertex ID of input vertices
  445. DWORD dwVIDOut; // Vertex ID of output vertices
  446. DWORD dwOutputSize; // Size of output vertices
  447. DWORD nTexCoord; // Number of the texture coordinate sets
  448. // Cache line starts here
  449. D3DDP_PTRSTRIDE textures[D3DDP_MAXTEXCOORD];
  450. // Cache line starts here
  451. // Output
  452. LPDWORD lpdwRStates; // Current render state vector
  453. D3DRECTV rExtents; // Extents rectangle to update, if required
  454. D3DMATRIXI mWV; // Transforms to camera space (Mworld*Mview)
  455. virtual HRESULT DrawPrim()=0; // Use to pass non-indexed primitives to the driver
  456. virtual HRESULT DrawIndexPrim()=0; // Use to pass indexed primitives to driver
  457. };
  458. // Prototype for the function to be written for a given processor implementation
  459. //
  460. // Returns clip intersection.
  461. //
  462. class ID3DFE_PVFUNCS
  463. {
  464. public:
  465. virtual ~ID3DFE_PVFUNCS() { };
  466. virtual DWORD ProcessVertices(LPD3DFE_PROCESSVERTICES)=0;
  467. virtual HRESULT ProcessPrimitive(LPD3DFE_PROCESSVERTICES)=0;
  468. virtual HRESULT ProcessIndexedPrimitive(LPD3DFE_PROCESSVERTICES)=0;
  469. virtual HRESULT OptimizeVertexBuffer
  470. (DWORD dwFVFID, // Vertex type. XYZ position is allowed
  471. DWORD dwNumVertices, // Number of vertices
  472. DWORD dwVertexSize, // Vertex size in bytes
  473. LPVOID lpSrcBuffer, // Source buffer.
  474. LPVOID lpDstBuffer, // Output buffer.
  475. DWORD dwFlags) // Should be zero for now
  476. {return E_NOTIMPL;}
  477. // Returns number of bytes to allocate for an optimized vertex buffer
  478. // This function is called before OptimizeVertexBuffer
  479. virtual DWORD ComputeOptimizedVertexBufferSize
  480. (DWORD dwFVF, // Vertex type
  481. DWORD dwVertexSize, // Vertex size in bytes
  482. DWORD dwNumVertices) // Number of vertices
  483. {return 0;}
  484. // This function could be used if PSGP doesn't want to implement complete
  485. // clipping pipeline
  486. // Parameters:
  487. // pv - state data
  488. // tri - triangle to clip
  489. // interpolate - interpolation flags
  490. // clipVertexPointer - pointer to an array of pointers to
  491. // generated vertices
  492. // Returns:
  493. // Number of vertices in clipped triangle
  494. // 0, if the triangle is off screen
  495. virtual int ClipSingleTriangle(D3DFE_PROCESSVERTICES *pv,
  496. ClipTriangle *tri,
  497. ClipVertex ***clipVertexPointer,
  498. int interpolate) = 0;
  499. virtual HRESULT ComputeSphereVisibility( LPD3DFE_PROCESSVERTICES pPV,
  500. LPD3DVECTOR lpCenters,
  501. LPD3DVALUE lpRadii,
  502. DWORD dwNumSpheres,
  503. DWORD dwFlags,
  504. LPDWORD lpdwReturnValues) = 0;
  505. // Used to generate clip flags for transformed and lit vertices
  506. // Computes clip status and returns clip intersection code
  507. virtual DWORD GenClipFlags(D3DFE_PROCESSVERTICES *pv);
  508. // Used to implement viewport->TransformVertices
  509. // Returns clip intersection code
  510. virtual DWORD TransformVertices(D3DFE_PROCESSVERTICES *pv,
  511. DWORD vertexCount,
  512. D3DTRANSFORMDATAI* data);
  513. };
  514. typedef ID3DFE_PVFUNCS *LPD3DFE_PVFUNCS;
  515. //---------------------------------------------------------------------
  516. // Direct3D implementation of PVFUNCS
  517. //
  518. class D3DFE_PVFUNCS : public ID3DFE_PVFUNCS
  519. {
  520. public:
  521. DWORD ProcessVertices(LPD3DFE_PROCESSVERTICES);
  522. HRESULT ProcessPrimitive(LPD3DFE_PROCESSVERTICES);
  523. HRESULT ProcessIndexedPrimitive(LPD3DFE_PROCESSVERTICES);
  524. virtual int ClipSingleTriangle(D3DFE_PROCESSVERTICES *pv,
  525. ClipTriangle *tri,
  526. ClipVertex ***clipVertexPointer,
  527. int interpolate);
  528. virtual HRESULT ComputeSphereVisibility( LPD3DFE_PROCESSVERTICES pPV,
  529. LPD3DVECTOR lpCenters,
  530. LPD3DVALUE lpRadii,
  531. DWORD dwNumSpheres,
  532. DWORD dwFlags,
  533. LPDWORD lpdwReturnValues);
  534. // Used to generate clip flags for transformed and lit vertices
  535. // Computes clip status and returns clip intersection code
  536. virtual DWORD GenClipFlags(D3DFE_PROCESSVERTICES *pv);
  537. // Used to implement viewport->TransformVertices
  538. virtual DWORD TransformVertices(D3DFE_PROCESSVERTICES *pv,
  539. DWORD vertexCount,
  540. D3DTRANSFORMDATAI* data);
  541. };
  542. // GeometrySetup function takes a DWORD describing the dirty bits and the new state vector
  543. // and passes back the 3 new leaf routines to use.
  544. typedef HRESULT (D3DAPI *LPD3DFE_CONTEXTCREATE)(DWORD dwFlags, LPD3DFE_PVFUNCS *lpLeafFuncs);
  545. // Global pointer to Processor specific PV setup routine
  546. // This is defined in dlld3d.cpp
  547. extern LPD3DFE_CONTEXTCREATE pfnFEContextCreate;
  548. #endif // _D3DFE_H