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.

242 lines
9.2 KiB

  1. /*==========================================================================;
  2. *
  3. * Copyright (C) 1994-1999 Microsoft Corporation. All Rights Reserved.
  4. *
  5. * File: ddithunk.h
  6. * Content: header file used by the NT DDI thunk layer
  7. * History:
  8. * Date By Reason
  9. * ==== == ======
  10. * 03-Dec-99 smac Created it
  11. *
  12. ***************************************************************************/
  13. #ifndef __DDITHUNK_INCLUDED__
  14. #define __DDITHUNK_INCLUDED__
  15. typedef struct _CACHEENTRY
  16. {
  17. LPDDRAWI_DDRAWSURFACE_INT pSurface;
  18. DWORD UsageStamp;
  19. } CACHEENTRY;
  20. typedef struct _DEFERREDCREATE
  21. {
  22. D3D8_CREATESURFACEDATA CreateData;
  23. struct _DEFERREDCREATE *pNext;
  24. } DEFERREDCREATE, *PDEFERREDCREATE;
  25. typedef struct _DDDEVICEHANDLE
  26. {
  27. LPDDRAWI_DIRECTDRAW_INT pDD;
  28. LPDDRAWI_DIRECTDRAW_INT pSwDD;
  29. DWLIST SurfaceHandleList;
  30. char szDeviceName[MAX_DRIVER_NAME];
  31. BOOL bDeviceLost;
  32. D3DFORMAT DisplayFormatWithAlpha;
  33. D3DFORMAT DisplayFormatWithoutAlpha;
  34. UINT DriverLevel;
  35. struct _DDCONTEXT* pContext;
  36. struct _DDSURFACE* pSurfList;
  37. struct _DDDEVICEHANDLE* pLink;
  38. struct _PALETTEINFO** pPaletteHandleTable;
  39. DWORD NumPaletteHandleEntries;
  40. LPDIRECTDRAWPALETTE pDefaultPalette;
  41. BOOL bCanTextureSysmem;
  42. DWORD PID;
  43. DWORD PCIID;
  44. DWORD DriverVersionHigh;
  45. DWORD DriverVersionLow;
  46. CACHEENTRY* pCachedSurfaceTable;
  47. int NumCachedSurfaces;
  48. DWORD CacheUsageStamp;
  49. DWORD ForceFlagsOn;
  50. DWORD ForceFlagsOff;
  51. BOOL bLightweight;
  52. VOID* pSwInitFunction;
  53. BOOL bDP2Error;
  54. PDEFERREDCREATE pDeferList;
  55. D3DDEVTYPE DeviceType;
  56. } DDDEVICEHANDLE, * PDDDEVICEHANDLE;
  57. typedef struct _DDSURFACE
  58. {
  59. // NOTE: dwCookie must be the first element
  60. // since we need easy access to it from the
  61. // client and the thunk layer itself.
  62. DWORD dwCookie;
  63. DWORD dwFlags;
  64. union
  65. {
  66. LPDDRAWI_DDRAWSURFACE_INT pHeavy;
  67. struct _LIGHTWEIGHTSURFACE* pLight;
  68. } Surface;
  69. union
  70. {
  71. BYTE* fpVidMem;
  72. LPDDRAWI_DDRAWSURFACE_INT pTempHeavy;
  73. };
  74. int Pitch;
  75. D3DPOOL Pool;
  76. D3DFORMAT Format;
  77. D3DRESOURCETYPE Type;
  78. DWORD Height;
  79. LPVOID pBits;
  80. DWORD LockFlags;
  81. RECT LockRect;
  82. PDDDEVICEHANDLE pDevice;
  83. struct _DDSURFACE* pNext;
  84. struct _DDSURFACE* pPrevious;
  85. int iSlicePitch;
  86. } DDSURFACE, * PDDSURFACE;
  87. #define DDSURFACE_LIGHTWEIGHT 0x00000001
  88. #define DDSURFACE_HEAVYWEIGHT 0x00000002
  89. #define DDSURFACE_ROOT 0x00000004
  90. #define DDSURFACE_LOCKRECT 0x00000008
  91. #define DDSURFACE_SOFTWARE 0x00000010
  92. #define DDSURFACE_HAL 0x00000020
  93. #define DDSURFACE_DX6HANDLE 0x00000040
  94. #define DDSURFACE_CREATECOMPLETE 0x00000080
  95. #define DDSURFACE_CREATEEX 0x00000100
  96. #define DDSURFACE_SYSMEMALLOCATED 0x00000200
  97. #define DDSURFACE_SYSMEMLOCK 0x00000400
  98. #define DDSURFACE_DEFERCREATEEX 0x00000800
  99. #define DDSURFACE_DEFERCREATETEXHANDLE 0x00001000
  100. #define DDSURFACE_DUMMY 0x00002000
  101. #define DDSURFACE_TREATASVIDMEM 0x00004000 // Flag to indicate that surf should
  102. // be treated as vid-mem for the
  103. // "do vid-mem surfaces exist" case
  104. typedef struct _DDCONTEXT
  105. {
  106. DWORD Context;
  107. void* pDPBuffer; // This is used to cache the pointer allocated at
  108. // context-create time
  109. // Clear emulation cache
  110. DWORD red_mask;
  111. DWORD red_scale;
  112. DWORD red_shift;
  113. DWORD green_mask;
  114. DWORD green_scale;
  115. DWORD green_shift;
  116. DWORD blue_mask;
  117. DWORD blue_scale;
  118. DWORD blue_shift;
  119. DWORD zmask_shift, stencilmask_shift;
  120. BOOL bDDSTargetIsPalettized; // true if 4 or 8 bit rendertarget
  121. DDDEVICEHANDLE* pDevice;
  122. // Used for defered creates
  123. DWORD dwFlags;
  124. DWORD dwTempContext;
  125. DWORD dwPID;
  126. DWORD ddrval;
  127. } DDCONTEXT, * PDDCONTEXT;
  128. #define DDCONTEXT_DEFER 0x00000001
  129. #define DDCONTEXT_DEFEREDTEXTUREHANDLES 0x00000002
  130. typedef struct _LIGHTWEIGHTSURFACE
  131. {
  132. // Members that go to the Lcl
  133. DWORD LclFlags;
  134. DWORD LclCaps1;
  135. ULONG_PTR LclReserved1;
  136. DWORD LclModeCreatedIn;
  137. DWORD LclBackBufferCount;
  138. // Members that go to the Gbl
  139. DWORD GblFlags;
  140. LONG GblPitch;
  141. DWORD GblWidth;
  142. ULONG_PTR GblReserved1;
  143. D3DFORMAT GblFormat;
  144. LPVMEMHEAP pGblVidMemHeap;
  145. FLATPTR fpGblVidMem;
  146. // Members that go to the More
  147. DWORD MoreCaps2;
  148. DWORD MoreCaps3;
  149. DWORD MoreCaps4;
  150. VOID* MoreRgjunc;
  151. // Members that go to the GblMore
  152. ULONG_PTR GblMoreDriverReserved;
  153. DWORD GblMoreContentsStamp;
  154. LPVOID pGblMoreUnswappedDriverReserved;
  155. FLATPTR fpGblMoreAliasOfVidMem;
  156. DWORD cGblMorePageUnlocks;
  157. // Unions to save memory
  158. union
  159. {
  160. FLATPTR fpGblMorePhysicalVidMem; // non-local vidmem
  161. FLATPTR fpGblMoreAliasedVidMem; // local vidmem
  162. DWORD MoreBytesAllocated; // sys mem
  163. };
  164. union
  165. {
  166. DWORD MoreMipMapCount; // Mipmaps
  167. DWORD MoreFVF; // Exe buffers
  168. };
  169. UINT CachedIndex; // ORed with INDEX_IN_USE if in use
  170. } LIGHTWEIGHTSURFACE, * PLIGHTWEIGHTSURFACE;
  171. #define INDEX_IN_USE 0x80000000
  172. typedef struct _PALETTEINFO
  173. {
  174. DDSURFACE* pSurface;
  175. LPDIRECTDRAWPALETTE pDDPalette;
  176. PALETTEENTRY ColorTable[256];
  177. } PALETTEINFO, * PPALETTEINFO;
  178. #define EXTRA_PALETTE_PADDING 25
  179. #define IS_SOFTWARE_DRIVER(x) \
  180. (((PDDDEVICEHANDLE)(x))->pSwDD != NULL)
  181. #define IS_SOFTWARE_DRIVER_SURFACE(x) \
  182. (((PDDSURFACE)(x))->dwFlags & DDSURFACE_SOFTWARE)
  183. #define IS_SURFACE_LOOSABLE(x) \
  184. (!IS_SOFTWARE_DRIVER_SURFACE(x) && \
  185. ((((PDDSURFACE)(x))->Pool == D3DPOOL_LOCALVIDMEM) || \
  186. (((PDDSURFACE)(x))->Pool == D3DPOOL_NONLOCALVIDMEM) || \
  187. (((PDDSURFACE)(x))->Pool == D3DPOOL_MANAGED)))
  188. #define INDEX_ENTRY(x) \
  189. ((x) & ~INDEX_IN_USE)
  190. #define GET_CACHED_ENTRY(x) \
  191. (&((x)->pDevice->pCachedSurfaceTable[INDEX_ENTRY((x)->Surface.pLight->CachedIndex)]))
  192. #define GET_CACHED_LIGHTWEIGHT_INT(x) \
  193. ((x)->pDevice->pCachedSurfaceTable[INDEX_ENTRY((x)->Surface.pLight->CachedIndex)].pSurface)
  194. // Function protoptypes
  195. extern void ConvertToOldFormat(LPDDPIXELFORMAT pOldFormat, D3DFORMAT NewFormat);
  196. extern void ConvertFromOldFormat(LPDDPIXELFORMAT pOldFormat, D3DFORMAT *pNewFormat);
  197. extern LPDDRAWI_DIRECTDRAW_INT SwDDICreateDirectDraw(void);
  198. extern void SwDDIMungeCaps (HINSTANCE hLibrary, HANDLE hDD, PD3D8_DRIVERCAPS pDriverCaps, PD3D8_CALLBACKS pCallbacks, LPDDSURFACEDESC, UINT*, VOID*);
  199. extern HRESULT SwDDICreateSurface(PD3D8_CREATESURFACEDATA pCreateSurface, DDSURFACEDESC2* pSurfDesc);
  200. extern void SwDDIAttachSurfaces (LPDDRAWI_DDRAWSURFACE_LCL pFrom, LPDDRAWI_DDRAWSURFACE_LCL pTo);
  201. extern void SwDDICreateSurfaceEx (LPDDRAWI_DIRECTDRAW_LCL pDrv, LPDDRAWI_DDRAWSURFACE_LCL pLcl);
  202. extern DWORD SwDDIDestroySurface (HANDLE hDD, PDDSURFACE pSurf, LPDDRAWI_DDRAWSURFACE_LCL pLcl);
  203. extern HRESULT SwDDILock (HANDLE hDD, PDDSURFACE pSurf, PD3D8_LOCKDATA pLockData, LPDDRAWI_DDRAWSURFACE_LCL pLcl);
  204. extern HRESULT SwDDIUnlock( HANDLE hDD, PDDSURFACE pSurf, D3D8_UNLOCKDATA* pUnlockData, LPDDRAWI_DDRAWSURFACE_LCL pLcl );
  205. extern LPDDRAWI_DDRAWSURFACE_INT MapLightweightSurface(DDSURFACE* pSurf);
  206. extern void UnmapLightweightSurface(DDSURFACE* pSurf);
  207. extern HRESULT MapLegacyResult(HRESULT hr);
  208. #endif