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.

793 lines
25 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1995-1997 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: d3di.h
  6. * Content: Direct3D internal include file
  7. *@@BEGIN_MSINTERNAL
  8. *
  9. * $Id: d3di.h,v 1.26 1995/12/04 11:29:44 sjl Exp $
  10. *
  11. * History:
  12. * Date By Reason
  13. * ==== == ======
  14. * 05/11/95 stevela Initial rev with this header.
  15. * 11/11/95 stevela Light code changed.
  16. * 21/11/95 colinmc Made Direct3D aggregatable
  17. * (so it can be QI'd off DirectDraw).
  18. * 23/11/95 colinmc Made Direct3D textures and devices aggregatable
  19. * (QI'd off DirectDrawSurfaces).
  20. * 07/12/95 stevela Merged in Colin's changes.
  21. * 10/12/95 stevela Removed AGGREGATE_D3D.
  22. * Removed Validate macros from here. Now in d3dpr.h
  23. * 02/03/96 colinmc Minor build fix
  24. * 17/04/96 stevela Use ddraw.h externally and ddrawp.h internally
  25. *@@END_MSINTERNAL
  26. *
  27. ***************************************************************************/
  28. #ifndef _D3DI_H
  29. #define _D3DI_H
  30. //@@BEGIN_MSINTERNAL
  31. #include "ddrawp.h"
  32. #if 0
  33. //@@END_MSINTERNAL
  34. #include "ddraw.h"
  35. //@@BEGIN_MSINTERNAL
  36. #endif
  37. //@@END_MSINTERNAL
  38. #include "d3dp.h"
  39. // @@BEGIN_MSINTERNAL
  40. #if !defined(BUILD_RLAPI) && !defined(BUILD_DDDDK)
  41. #include "ddrawi.h"
  42. #include "rlreg.h"
  43. #include "lists.h"
  44. #include "object.h"
  45. /*
  46. INDEX_BATCH_SCALE is the constant which is used by DrawIndexedPrim
  47. to deterimine if the number of primitives being drawn is small
  48. relative to the number of vertices being passed. If it is then
  49. the prims are dereferenced in batches and sent to DrawPrim.
  50. */
  51. #define INDEX_BATCH_SCALE 2
  52. /*
  53. typedef D3DCOLORMODEL D3DCOLORMODEL;
  54. #define D3DCOLOR_RAMP D3DCOLOR_RAMP
  55. #define D3DCOLOR_RGB D3DCOLOR_RGB
  56. #define D3D_COLORMODEL D3D_COLORMODEL
  57. */
  58. #endif /* !BUILD_RLAPI */
  59. // @@END_MSINTERNAL
  60. typedef DWORD D3DI_BUFFERHANDLE, *LPD3DI_BUFFERHANDLE;
  61. /*
  62. * Internal version of executedata
  63. */
  64. typedef struct _D3DI_ExecuteData {
  65. DWORD dwSize;
  66. D3DI_BUFFERHANDLE dwHandle; /* Handle allocated by driver */
  67. DWORD dwVertexOffset;
  68. DWORD dwVertexCount;
  69. DWORD dwInstructionOffset;
  70. DWORD dwInstructionLength;
  71. DWORD dwHVertexOffset;
  72. D3DSTATUS dsStatus; /* Status after execute */
  73. } D3DI_EXECUTEDATA, *LPD3DI_EXECUTEDATA;
  74. /*
  75. * Internal version of lightdata and constants for flags
  76. */
  77. #define D3DLIGHTI_ATT0_IS_NONZERO (0x00010000)
  78. #define D3DLIGHTI_ATT1_IS_NONZERO (0x00020000)
  79. #define D3DLIGHTI_ATT2_IS_NONZERO (0x00040000)
  80. #define D3DLIGHTI_LINEAR_FALLOFF (0x00080000)
  81. #define D3DLIGHTI_UNIT_SCALE (0x00100000)
  82. #define D3DLIGHTI_LIGHT_AT_EYE (0x00200000)
  83. typedef struct _D3DI_LIGHT {
  84. D3DLIGHTTYPE type;
  85. DWORD version; /* matches number on D3DLIGHT struct */
  86. BOOL valid;
  87. D3DVALUE red, green, blue, shade;
  88. D3DVECTOR position;
  89. D3DVECTOR model_position;
  90. D3DVECTOR direction;
  91. D3DVECTOR model_direction;
  92. D3DVECTOR halfway;
  93. D3DVECTOR model_eye; /* direction from eye in model space */
  94. D3DVECTOR model_scale; /* model scale for proper range computations */
  95. D3DVALUE range;
  96. D3DVALUE range_squared;
  97. D3DVALUE falloff;
  98. D3DVALUE attenuation0;
  99. D3DVALUE attenuation1;
  100. D3DVALUE attenuation2;
  101. D3DVALUE cos_theta_by_2;
  102. D3DVALUE cos_phi_by_2;
  103. DWORD flags;
  104. } D3DI_LIGHT, *LPD3DI_LIGHT;
  105. // @@BEGIN_MSINTERNAL
  106. #if !defined(BUILD_RLAPI) && !defined(BUILD_DDDDK)
  107. #ifndef BUILD_HEL
  108. #ifdef BUILD_D3D_LAYER
  109. #include "driver.h"
  110. #endif
  111. typedef struct IUnknownVtbl D3DUNKNOWNCALLBACKS, *LPD3DUNKNOWNCALLBACKS;
  112. typedef struct ID3DObjectVtbl D3DOBJECTVTBL, *LPD3DOBJECTVTBL;
  113. typedef struct IDirect3DVtbl DIRECT3DCALLBACKS, *LPDIRECT3DCALLBACKS;
  114. typedef struct IDirect3D2Vtbl DIRECT3D2CALLBACKS, *LPDIRECT3D2CALLBACKS;
  115. typedef struct IDirect3DDeviceVtbl DIRECT3DDEVICECALLBACKS, *LPDIRECT3DDEVICECALLBACKS;
  116. typedef struct IDirect3DDevice2Vtbl DIRECT3DDEVICE2CALLBACKS, *LPDIRECT3DDEVICE2CALLBACKS;
  117. typedef struct IDirect3DExecuteBufferVtbl DIRECT3DEXECUTEBUFFERCALLBACKS, *LPDIRECT3DEXECUTEBUFFERCALLBACKS;
  118. typedef struct IDirect3DLightVtbl DIRECT3DLIGHTCALLBACKS, *LPDIRECT3DLIGHTCALLBACKS;
  119. typedef struct IDirect3DMaterialVtbl DIRECT3DMATERIALCALLBACKS, *LPDIRECT3DMATERIALCALLBACKS;
  120. typedef struct IDirect3DMaterial2Vtbl DIRECT3DMATERIAL2CALLBACKS, *LPDIRECT3DMATERIAL2CALLBACKS;
  121. typedef struct IDirect3DTextureVtbl DIRECT3DTEXTURECALLBACKS, *LPDIRECT3DTEXTURECALLBACKS;
  122. typedef struct IDirect3DTexture2Vtbl DIRECT3DTEXTURE2CALLBACKS, *LPDIRECT3DTEXTURE2CALLBACKS;
  123. typedef struct IDirect3DViewport2Vtbl DIRECT3DVIEWPORT2CALLBACKS, *LPDIRECT3DVIEWPORT2CALLBACKS;
  124. #ifdef __cplusplus
  125. extern "C" {
  126. #endif
  127. typedef struct _DIRECT3DI *LPDIRECT3DI;
  128. typedef struct _DIRECT3DDEVICEI *LPDIRECT3DDEVICEI;
  129. typedef struct _DIRECT3DEXECUTEBUFFERI *LPDIRECT3DEXECUTEBUFFERI;
  130. typedef struct _DIRECT3DLIGHTI *LPDIRECT3DLIGHTI;
  131. typedef struct _DIRECT3DMATERIALI *LPDIRECT3DMATERIALI;
  132. typedef struct _DIRECT3DTEXTUREI *LPDIRECT3DTEXTUREI;
  133. typedef struct _DIRECT3DVIEWPORTI *LPDIRECT3DVIEWPORTI;
  134. /*
  135. * If we have an aggregate Direct3D we need a structure to
  136. * represent an interface distinct from the underlying
  137. * object. This is that structure. None of this would be necessary
  138. * in C++
  139. */
  140. typedef struct _DIRECT3DUNKNOWNI
  141. {
  142. LPD3DUNKNOWNCALLBACKS lpVtbl;
  143. LPDIRECT3DI lpObj;
  144. } DIRECT3DUNKNOWNI;
  145. typedef struct _DIRECT3DUNKNOWNI *LPDIRECT3DUNKNOWNI;
  146. typedef struct _DIRECT3DOLDI
  147. {
  148. LPDIRECT3DCALLBACKS lpVtbl;
  149. LPDIRECT3DI lpObj;
  150. } DIRECT3DOLDI;
  151. typedef struct _DIRECT3DOLDI *LPDIRECT3DOLDI;
  152. /*
  153. * Internal version of Direct3D object; it has data after the vtable
  154. */
  155. typedef struct _DIRECT3DI
  156. {
  157. /*** Object Interface ***/
  158. LPDIRECT3D2CALLBACKS lpVtbl; /* Pointer to callbacks */
  159. int refCnt; /* Reference count object */
  160. /*** Object Relations ***/
  161. /* Devices */
  162. int numDevs;/* Number of devices */
  163. LIST_ROOT(_devices, _DIRECT3DDEVICEI) devices;
  164. /* Associated IDirect3DDevices */
  165. /* Viewports */
  166. int numViewports; /* Number of viewports */
  167. LIST_ROOT(_viewports, _DIRECT3DVIEWPORTI) viewports;
  168. /* Created IDirect3DViewports */
  169. /* Lights */
  170. int numLights; /* Number of lights */
  171. LIST_ROOT(_lights, _DIRECT3DLIGHTI) lights;
  172. /* Created IDirect3DLights */
  173. /* Materials */
  174. int numMaterials; /* Number of materials */
  175. LIST_ROOT(_materials, _DIRECT3DMATERIALI) materials;
  176. /* Created IDirect3DMaterials */
  177. /*** Object Data ***/
  178. unsigned long v_next; /* id of next viewport to be created */
  179. RLDDIRegistry* lpReg; /* Registry */
  180. /*
  181. * DirectDraw Interface
  182. */
  183. LPDDRAWI_DIRECTDRAW_INT lpDDInt;
  184. /*
  185. * The special IUnknown interface for the aggregate that does
  186. * not punt to the parent object.
  187. */
  188. LPUNKNOWN lpOwningIUnknown; /* The owning IUnknown */
  189. DIRECT3DUNKNOWNI lpThisIUnknown; /* Our IUnknown interface */
  190. DIRECT3DOLDI lpThisIDirect3D; /* Our IDirect3D interface */
  191. DWORD dwVersion; /* 1 for legacy D3D, 2 for D3D2 */
  192. } DIRECT3DI;
  193. /*
  194. * If we have an aggreate Direct3DDevice we need a structure to
  195. * represent an interface distinct from the underlying
  196. * object. This is that structure.
  197. */
  198. typedef struct _DIRECT3DDEVICEUNKNOWNI
  199. {
  200. LPDIRECT3DDEVICE2CALLBACKS lpVtbl;
  201. LPDIRECT3DDEVICEI lpObj;
  202. } DIRECT3DDEVICEUNKNOWNI;
  203. typedef struct _DIRECT3DDEVICEUNKNOWNI *LPDIRECT3DDEVICEUNKNOWNI;
  204. typedef struct _DIRECT3DDEVICEOLDI
  205. {
  206. LPDIRECT3DDEVICECALLBACKS lpVtbl;
  207. LPDIRECT3DDEVICEI lpObj;
  208. } DIRECT3DDEVICEOLDI;
  209. typedef struct _DIRECT3DDEVICEOLDI *LPDIRECT3DDEVICEOLDI;
  210. /*
  211. * Internal version of Direct3DDevice object; it has data after the vtable
  212. */
  213. #include "d3dhal.h"
  214. typedef RLDDIDriver* (*RLDDIDDrawCreateDriverFn)(
  215. LPDDRAWI_DIRECTDRAW_INT lpDDInt,
  216. LPDIRECTDRAWSURFACE lpDDS,
  217. LPDIRECTDRAWSURFACE lpZ,
  218. LPDIRECTDRAWPALETTE lpPal,
  219. LPDIRECT3DDEVICEI);
  220. typedef HRESULT (*RLDDIGetCapsFn)(LPD3DDEVICEDESC*, LPD3DDEVICEDESC*);
  221. typedef void (*RLDDIInitFn)(RLDDIMallocFn, RLDDIReallocFn, RLDDIFreeFn, RLDDIRaiseFn, RLDDIValue**, int, int);
  222. typedef void (*RLDDIPushDriverFn)(RLDDIDriverStack*, RLDDIDriver*);
  223. typedef void (*RLDDIPopDriverFn)(RLDDIDriverStack*);
  224. struct _RLDDIGenRasDriver;
  225. typedef struct _RLDDIGenRasDriver* LPRLDDIGENRASDRIVER;
  226. struct _RLDDIDDrawDriver;
  227. typedef struct _RLDDIDDrawDriver* LPRLDDIDDRAWDRIVER;
  228. struct _RLDDITransformDriver;
  229. typedef struct _RLDDITransformDriver* LPRLDDITRANSFORMDRIVER;
  230. typedef HRESULT (*PFNLOCKTEXTURE)(LPRLDDIGENRASDRIVER driver);
  231. typedef void (*PFNUNLOCKTEXTURE)(LPRLDDIGENRASDRIVER driver);
  232. typedef int (*PFNSETFILLPARAMS)(LPRLDDIGENRASDRIVER driver, D3DSTATE* in_params,
  233. int count);
  234. typedef HRESULT (*PFNREALLOCALIGNED)(void** p_inout, size_t size);
  235. typedef HRESULT (*PFNMALLOCALIGNED)(void** p_inout, size_t size);
  236. typedef HRESULT (*PFNFREEALIGNED)(void* p_inout);
  237. typedef HRESULT (*PFNDRVSETRENDERTARGET)(LPDIRECTDRAWSURFACE, LPDIRECTDRAWSURFACE,
  238. LPDIRECTDRAWPALETTE, LPDIRECT3DDEVICEI);
  239. typedef HRESULT (*PFNDOFLUSHBEGINEND)(LPDIRECT3DDEVICE2, DWORD);
  240. typedef HRESULT (*PFNDRAWPRIMITIVES)(LPDIRECT3DDEVICEI, LPD3DTLVERTEX, LPVOID, LPD3DINSTRUCTION, DWORD);
  241. typedef struct _D3DI_TEXTUREBLOCK
  242. {
  243. LIST_MEMBER(_D3DI_TEXTUREBLOCK) list;
  244. /* Next block in IDirect3DTexture */
  245. LIST_MEMBER(_D3DI_TEXTUREBLOCK) devList;
  246. /* Next block in IDirect3DDevice */
  247. LPDIRECT3DDEVICEI lpD3DDeviceI;
  248. LPDIRECT3DTEXTUREI lpD3DTextureI;
  249. D3DTEXTUREHANDLE hTex;
  250. /* texture handle */
  251. } D3DI_TEXTUREBLOCK;
  252. typedef struct _D3DI_TEXTUREBLOCK *LPD3DI_TEXTUREBLOCK;
  253. typedef struct _D3DI_MATERIALBLOCK
  254. {
  255. LIST_MEMBER(_D3DI_MATERIALBLOCK) list;
  256. /* Next block in IDirect3DMaterial */
  257. LIST_MEMBER(_D3DI_MATERIALBLOCK) devList;
  258. /* Next block in IDirect3DDevice */
  259. LPDIRECT3DDEVICEI lpD3DDeviceI;
  260. LPDIRECT3DMATERIALI lpD3DMaterialI;
  261. D3DMATERIALHANDLE hMat;
  262. /* material handle */
  263. } D3DI_MATERIALBLOCK;
  264. typedef struct _D3DI_MATERIALBLOCK *LPD3DI_MATERIALBLOCK;
  265. #define D3D_RSTATEBUF_SIZE 128
  266. #define D3D_MAX_RSTATES 96 /* Last render state ID + 1 */
  267. #define D3D_MAX_MMX_VERTICES 1024
  268. extern DWORD dwD3DTriBatchSize, dwTriBatchSize, dwLineBatchSize;
  269. extern DWORD dwHWBufferSize, dwHWMaxTris;
  270. extern DWORD dwHWFewVertices;
  271. typedef struct _D3DHAL_DRAWPRIMCOUNTS *LPD3DHAL_DRAWPRIMCOUNTS;
  272. // Legacy HAL batching is done with these structs.
  273. typedef struct _D3DI_HWCOUNTS {
  274. WORD wNumStateChanges; // Number of state changes batched
  275. WORD wNumVertices; // Number of vertices in tri list
  276. WORD wNumTriangles; // Number of triangles in tri list
  277. } D3DI_HWCOUNTS, *LPD3DI_HWCOUNTS;
  278. typedef struct _DIRECT3DDEVICEI
  279. {
  280. /*** Object Interface ***/
  281. LPDIRECT3DDEVICE2CALLBACKS lpVtbl; /* Pointer to callbacks */
  282. int refCnt; /* Reference count */
  283. /*** Object Relations ***/
  284. LPDIRECT3DI lpDirect3DI; /* parent */
  285. LIST_MEMBER(_DIRECT3DDEVICEI)list; /* Next device IDirect3D */
  286. /* Textures */
  287. LIST_ROOT(_textures, _D3DI_TEXTUREBLOCK) texBlocks;
  288. /* Ref to created IDirect3DTextures */
  289. /* Execute buffers */
  290. LIST_ROOT(_buffers, _DIRECT3DEXECUTEBUFFERI) buffers;
  291. /* Created IDirect3DExecuteBuffers */
  292. /* Viewports */
  293. int numViewports;
  294. CIRCLE_QUEUE_ROOT(_dviewports, _DIRECT3DVIEWPORTI) viewports;
  295. /* Associated IDirect3DViewports */
  296. LPDIRECT3DVIEWPORT2 lpCurrentViewport;
  297. /* Materials */
  298. LIST_ROOT(_dmmaterials, _D3DI_MATERIALBLOCK) matBlocks;
  299. /* Ref to associated IDirect3DMaterials */
  300. /*** Object Data ***/
  301. /* Private interfaces */
  302. LPD3DOBJECTVTBL lpClassVtbl; /* Private Vtbl */
  303. LPD3DOBJECTVTBL lpObjVtbl; /* Private Vtbl */
  304. LPD3DHAL_CALLBACKS lpD3DHALCallbacks; /* HW specific */
  305. LPD3DHAL_GLOBALDRIVERDATA lpD3DHALGlobalDriverData; /* HW specific */
  306. /* Viewports */
  307. unsigned long v_id; /* ID of last viewport rendered */
  308. /* Lights */
  309. int numLights;
  310. /* This indicates the maximum number
  311. of lights that have been set in
  312. the device. */
  313. /* Device characteristics */
  314. int age;
  315. int width;
  316. int height;
  317. int depth;
  318. unsigned long red_mask, green_mask, blue_mask;
  319. int dither;
  320. int ramp_size; /* SW specific */
  321. D3DCOLORMODEL color_model;
  322. int wireframe_options;
  323. D3DTEXTUREFILTER texture_quality;
  324. D3DVALUE gamma;
  325. unsigned char gamma_table[256];
  326. int aspectx, aspecty;
  327. D3DVALUE perspective_tolerance;
  328. /* Library information */
  329. #ifdef WIN32
  330. HINSTANCE hDrvDll;
  331. char dllname[MAXPATH];
  332. char base[256];
  333. #endif
  334. #ifdef SHLIB
  335. void* so;
  336. #endif
  337. /* Are we in a scene? */
  338. BOOL bInScene;
  339. /* Our Device type */
  340. GUID guid;
  341. /* GetCaps function from the library */
  342. RLDDIGetCapsFn GetCapsFn;
  343. /* Functions required to build driver */
  344. RLDDIInitFn RLDDIInit;
  345. RLDDIPushDriverFn RLDDIPushDriver;
  346. RLDDIPopDriverFn RLDDIPopDriver;
  347. RLDDIDDrawCreateDriverFn RLDDIDDrawCreateDriver;
  348. /* Device description */
  349. D3DDEVICEDESC d3dHWDevDesc;
  350. D3DDEVICEDESC d3dHELDevDesc;
  351. /* Driver stack */
  352. RLDDIDriverStack* stack;
  353. /*
  354. * The special IUnknown interface for the aggregate that does
  355. * not punt to the parent object.
  356. */
  357. LPUNKNOWN lpOwningIUnknown; /* The owning IUnknown */
  358. DIRECT3DDEVICEUNKNOWNI lpThisIUnknown; /* Our IUnknown interface */
  359. DIRECT3DDEVICEOLDI lpThisID3DDev; /* Our IDirect3DDevice interface */
  360. LPD3DHAL_CALLBACKS2 lpD3DHALCallbacks2; /* HW specific */
  361. /*
  362. * Renderstate cache for DrawPrimitive
  363. */
  364. WORD wRStateBufLevel;
  365. D3DSTATE renStateBuf[D3D_RSTATEBUF_SIZE];
  366. /* Pointers to drivers used by DrawPrimitive */
  367. LPRLDDIGENRASDRIVER rasDriver; /* SW specific */
  368. LPRLDDITRANSFORMDRIVER xfmDriver; /* Assumed to be NULL for HW */
  369. LPRLDDIDDRAWDRIVER drawDriver; /* Assumed to be NULL for HW */
  370. /*
  371. * Pointers to functions used by DrawPrim&Begin/End
  372. */
  373. PFNLOCKTEXTURE pfnLockTexture; /* SW specific */
  374. PFNUNLOCKTEXTURE pfnUnlockTexture; /* SW specific */
  375. PFNSETFILLPARAMS pfnSetFillParams; /* SW specific */
  376. PFNREALLOCALIGNED pfnReallocAligned; /* SW specific */
  377. PFNDRVSETRENDERTARGET pfnDrvSetRenderTarget; /* SW specific */
  378. HRESULT (*pfnFlushStates)(struct _DIRECT3DDEVICEI*);
  379. PFNDOFLUSHBEGINEND pfnDoFlushBeginEnd;
  380. PFNDRAWPRIMITIVES pfnDrawPrimitives;
  381. /* Are we between Begin/End? */
  382. BOOL bInBegin;
  383. D3DVERTEXTYPE vtVertexType;
  384. D3DPRIMITIVETYPE ptPrimitiveType;
  385. CRITICAL_SECTION BeginEndCSect;
  386. // max number of vertices
  387. #define BEGIN_DATA_BLOCK_SIZE 256
  388. LPVOID lpvVertexBatch;
  389. WORD *lpIndexBatch;
  390. // lpvVertexData is non-NULL if we are InBegin and indexed.
  391. LPVOID lpvVertexData;
  392. DWORD dwNumVertices;
  393. DWORD dwMaxVertexCount; // current number of vertices there is space for
  394. WORD *lpVertexIndices;
  395. DWORD dwNumIndices;
  396. DWORD dwMaxIndexCount; // current number of indices there is space for
  397. DWORD dwFlags;
  398. WORD wFlushed;
  399. /*
  400. * DrawPrimitives batching
  401. */
  402. // Buffer to put DrawPrimitives stuff into
  403. // Used for both legacy and DrawPrimitive HALs
  404. WORD *lpwDPBuffer;
  405. WORD *lpwDPBufferAlloced;
  406. /* Legacy HALs */
  407. // pointer to current prim counts struct
  408. LPD3DHAL_DRAWPRIMCOUNTS lpDPPrimCounts;
  409. // Buffer of counts structures that keep track of the
  410. // number of render states and vertices buffered
  411. LPD3DI_HWCOUNTS lpHWCounts;
  412. // Buffer of triangle structures.
  413. LPD3DTRIANGLE lpHWTris;
  414. // Buffer of interleaved render states and primitives.
  415. LPD3DTLVERTEX lpHWVertices;
  416. // Byte offset into lpHWVertices. This gets incremented
  417. // by 8 when a render state is batched and by 32*dwNumVertices
  418. // when a primitive is batched.
  419. DWORD dwHWOffset;
  420. // Max value of dwHWOffset. Used to decide whether to flush.
  421. DWORD dwHWMaxOffset;
  422. // Index into lpHWTris.
  423. DWORD dwHWTriIndex;
  424. // Number of counts structures used so far. This actually
  425. // gives the number of primitives batched and the index of
  426. // the counts structure to batch render states into.
  427. DWORD dwHWNumCounts;
  428. /* DrawPrimitive-aware HALs */
  429. // Byte offset into buffer (we are currently
  430. // using the device's wTriIndex)
  431. DWORD dwDPOffset;
  432. // Maximum offset. If dwDPOffset exceeds this, it is
  433. // time to flush.
  434. DWORD dwDPMaxOffset;
  435. WORD *wTriIndex;
  436. // buffers for TL and H vertices
  437. LPD3DTLVERTEX lpTLVbuf;
  438. LPD3DHVERTEX lpHVbuf;
  439. DWORD dwVbufSize;
  440. LPD3DHAL_D3DEXTENDEDCAPS lpD3DExtendedCaps; /* HW specific */
  441. } DIRECT3DDEVICEI;
  442. /*
  443. * Internal version of Direct3DExecuteBuffer object;
  444. * it has data after the vtable
  445. */
  446. typedef struct _DIRECT3DEXECUTEBUFFERI
  447. {
  448. /*** Object Interface ***/
  449. LPDIRECT3DEXECUTEBUFFERCALLBACKS lpVtbl; /* Pointer to callbacks */
  450. int refCnt; /* Reference count */
  451. /*** Object Relations ***/
  452. LPDIRECT3DDEVICEI lpD3DDeviceI; /* Parent */
  453. LIST_MEMBER(_DIRECT3DEXECUTEBUFFERI)list;
  454. /* Next buffer in IDirect3D */
  455. /*** Object Data ***/
  456. DWORD pid; /* Process locking execute buffer */
  457. D3DEXECUTEBUFFERDESC debDesc;
  458. /* Description of the buffer */
  459. D3DEXECUTEDATA exData; /* Execute Data */
  460. BOOL locked; /* Is the buffer locked */
  461. D3DI_BUFFERHANDLE hBuf;
  462. /* Execute buffer handle */
  463. } DIRECT3DEXECUTEBUFFERI;
  464. /*
  465. * Internal version of Direct3DLight object;
  466. * it has data after the vtable
  467. */
  468. typedef struct _DIRECT3DLIGHTI
  469. {
  470. /*** Object Interface ***/
  471. LPDIRECT3DLIGHTCALLBACKS lpVtbl; /* Pointer to callbacks */
  472. int refCnt; /* Reference count */
  473. /*** Object Relations ***/
  474. LPDIRECT3DI lpDirect3DI; /* Parent */
  475. LIST_MEMBER(_DIRECT3DLIGHTI)list;
  476. /* Next light in IDirect3D */
  477. LPDIRECT3DVIEWPORTI lpD3DViewportI; /* Guardian */
  478. CIRCLE_QUEUE_MEMBER(_DIRECT3DLIGHTI)light_list;
  479. /* Next light in IDirect3DViewport */
  480. /*** Object Data ***/
  481. D3DLIGHT2 dlLight;/* Data describing light */
  482. D3DI_LIGHT diLightData;
  483. /* Internal representation of light */
  484. } DIRECT3DLIGHTI;
  485. typedef struct _DIRECT3DMATERIALOLDI
  486. {
  487. LPDIRECT3DMATERIALCALLBACKS lpVtbl;
  488. LPDIRECT3DMATERIALI lpObj;
  489. } DIRECT3DMATERIALOLDI, *LPDIRECT3DMATERIALOLDI;
  490. /*
  491. * Internal version of Direct3DMaterial object;
  492. * it has data after the vtable
  493. */
  494. typedef struct _DIRECT3DMATERIALI
  495. {
  496. /*** Object Interface ***/
  497. LPDIRECT3DMATERIAL2CALLBACKS lpVtbl; /* Pointer to callbacks */
  498. int refCnt; /* Reference count */
  499. /*** Object Relations ***/
  500. LPDIRECT3DI lpDirect3DI; /* Parent */
  501. DIRECT3DMATERIALOLDI lpThisID3DMat; /* Our IDirect3DMaterial interface */
  502. LIST_MEMBER(_DIRECT3DMATERIALI)list;
  503. /* Next MATERIAL in IDirect3D */
  504. LIST_ROOT(_mblocks, _D3DI_MATERIALBLOCK)blocks;
  505. /* devices we're associated with */
  506. /*** Object Data ***/
  507. D3DMATERIAL dmMaterial; /* Data describing material */
  508. BOOL bRes; /* Is this material reserved in the driver */
  509. } DIRECT3DMATERIALI;
  510. /*
  511. * If we have an aggreate Direct3DTexture we need a structure
  512. * to represent an unknown interface distinct from the underlying
  513. * object. This is that structure.
  514. */
  515. typedef struct _DIRECT3DTEXTUREUNKNOWNI
  516. {
  517. LPDIRECT3DTEXTURECALLBACKS lpVtbl;
  518. LPDIRECT3DTEXTUREI lpObj;
  519. } DIRECT3DTEXTUREUNKNOWNI;
  520. typedef struct _DIRECT3DTEXTUREUNKNOWNI *LPDIRECT3DTEXTUREUNKNOWNI;
  521. typedef struct _DIRECT3DTEXTUREOLDI
  522. {
  523. LPDIRECT3DTEXTURECALLBACKS lpVtbl;
  524. LPDIRECT3DTEXTUREI lpObj;
  525. } DIRECT3DTEXTUREOLDI, *LPDIRECT3DTEXTUREOLDI;
  526. /*
  527. * Internal version of Direct3DTexture object; it has data after the vtable
  528. */
  529. typedef struct _DIRECT3DTEXTUREI
  530. {
  531. /*** Object Interface ***/
  532. LPDIRECT3DTEXTURE2CALLBACKS lpVtbl; /* Pointer to callbacks */
  533. int refCnt; /* Reference count */
  534. /*** Object Relations ***/
  535. LIST_ROOT(_blocks, _D3DI_TEXTUREBLOCK) blocks;
  536. /* Devices we're associated with */
  537. /*** Object Data ***/
  538. LPDIRECTDRAWSURFACE lpDDS;
  539. /*
  540. * The special IUnknown interface for the aggregate that does
  541. * not punt to the parent object.
  542. */
  543. LPUNKNOWN lpOwningIUnknown; /* The owning IUnknown */
  544. DIRECT3DTEXTUREUNKNOWNI lpThisIUnknown; /* Our IUnknown interface */
  545. DIRECT3DTEXTUREOLDI lpThisID3DTex; /* Our IDirect3DTexture interface */
  546. BOOL bIsPalettized;
  547. } DIRECT3DTEXTUREI;
  548. /*
  549. * Internal version of Direct3DViewport object; it has data after the vtable
  550. */
  551. typedef struct _DIRECT3DVIEWPORTI
  552. {
  553. /*** Object Interface ***/
  554. LPDIRECT3DVIEWPORT2CALLBACKS lpVtbl; /* Pointer to callbacks */
  555. int refCnt; /* Reference count */
  556. /*** Object Relations */
  557. LPDIRECT3DI lpDirect3DI; /* Parent */
  558. LIST_MEMBER(_DIRECT3DVIEWPORTI)list;
  559. /* Next viewport in IDirect3D */
  560. LPDIRECT3DDEVICEI lpD3DDeviceI; /* Guardian */
  561. CIRCLE_QUEUE_MEMBER(_DIRECT3DVIEWPORTI)vw_list;
  562. /* Next viewport in IDirect3DDevice */
  563. /* Lights */
  564. int numLights;
  565. CIRCLE_QUEUE_ROOT(_dlights, _DIRECT3DLIGHTI) lights;
  566. /* Associated IDirect3DLights */
  567. /*** Object Data ***/
  568. unsigned long v_id; /* Id for this viewport */
  569. D3DVIEWPORT2 v_data;
  570. BOOL v_data_is_set;
  571. BOOL have_background;
  572. D3DMATERIALHANDLE background;
  573. /* Background material */
  574. BOOL have_depth;
  575. LPDIRECTDRAWSURFACE depth; /* Background depth */
  576. BOOL bLightsChanged;
  577. /* Have the lights changed since they
  578. were last collected? */
  579. DWORD clrCount; /* Number of rects allocated */
  580. LPD3DRECT clrRects; /* Rects used for clearing */
  581. } DIRECT3DVIEWPORTI;
  582. /*
  583. * Picking stuff.
  584. */
  585. typedef struct _D3DI_PICKDATA {
  586. D3DI_EXECUTEDATA* exe;
  587. D3DPICKRECORD* records;
  588. int pick_count;
  589. D3DRECT pick;
  590. } D3DI_PICKDATA, *LPD3DI_PICKDATA;
  591. /*
  592. * Direct3D memory allocation
  593. */
  594. /*
  595. * Register a set of functions to be used in place of malloc, realloc
  596. * and free for memory allocation. The functions D3DMalloc, D3DRealloc
  597. * and D3DFree will use these functions. The default is to use the
  598. * ANSI C library routines malloc, realloc and free.
  599. */
  600. typedef LPVOID (*D3DMALLOCFUNCTION)(size_t);
  601. typedef LPVOID (*D3DREALLOCFUNCTION)(LPVOID, size_t);
  602. typedef VOID (*D3DFREEFUNCTION)(LPVOID);
  603. /*
  604. * Allocate size bytes of memory and return a pointer to it in *p_return.
  605. * Returns D3DERR_BADALLOC with *p_return unchanged if the allocation fails.
  606. */
  607. HRESULT D3DAPI D3DMalloc(LPVOID* p_return, size_t size);
  608. /*
  609. * Change the size of an allocated block of memory. A pointer to the
  610. * block is passed in in *p_inout. If *p_inout is NULL then a new
  611. * block is allocated. If the reallocation is successful, *p_inout is
  612. * changed to point to the new block. If the allocation fails,
  613. * *p_inout is unchanged and D3DERR_BADALLOC is returned.
  614. */
  615. HRESULT D3DAPI D3DRealloc(LPVOID* p_inout, size_t size);
  616. /*
  617. * Free a block of memory previously allocated with D3DMalloc or
  618. * D3DRealloc.
  619. */
  620. VOID D3DAPI D3DFree(LPVOID p);
  621. /*
  622. * Used for raising errors from the driver.
  623. */
  624. HRESULT D3DAPI D3DRaise(HRESULT);
  625. /*
  626. * Convert RLDDI error codes to D3D error codes
  627. */
  628. #define RLDDITOD3DERR(_errcode) (RLDDIToD3DErrors[_errcode])
  629. extern HRESULT RLDDIToD3DErrors[];
  630. /*
  631. * maths
  632. */
  633. #if 1 /* defined(STACK_CALL) && defined(__WATCOMC__) */
  634. D3DVALUE D3DIPow(D3DVALUE, D3DVALUE);
  635. #else
  636. #define D3DIPow(v,p) DTOVAL(pow(VALTOD(v), VALTOD(p)))
  637. #endif
  638. /*
  639. * Light utils
  640. */
  641. void D3DI_DeviceMarkLightEnd(LPDIRECT3DDEVICEI, int);
  642. void D3DI_UpdateLightInternal(LPDIRECT3DLIGHTI);
  643. void D3DI_VectorNormalise12(LPD3DVECTOR v);
  644. D3DTEXTUREHANDLE D3DI_FindTextureHandle(LPDIRECT3DTEXTUREI, LPDIRECT3DDEVICEI);
  645. void D3DI_SetTextureHandle(LPDIRECT3DTEXTUREI, LPDIRECT3DDEVICEI, D3DTEXTUREHANDLE);
  646. void D3DI_RemoveTextureBlock(LPD3DI_TEXTUREBLOCK);
  647. void D3DI_RemoveMaterialBlock(LPD3DI_MATERIALBLOCK);
  648. extern BOOL D3DI_isHALValid(LPD3DHAL_CALLBACKS);
  649. #ifdef BUILD_D3D_LAYER
  650. extern RLDDIValue* RLDDIFInvSqrtTable;
  651. #endif
  652. #ifdef __cplusplus
  653. };
  654. #endif
  655. #endif /* BUILD_HEL */
  656. #endif /* !BUILD_RLAPI */
  657. // @@END_MSINTERNAL
  658. #endif /* _D3DI_H */