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.

405 lines
13 KiB

  1. /******************************Module*Header*******************************\
  2. *
  3. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  4. * !! !!
  5. * !! WARNING: NOT DDK SAMPLE CODE !!
  6. * !! !!
  7. * !! This source code is provided for completeness only and should not be !!
  8. * !! used as sample code for display driver development. Only those sources !!
  9. * !! marked as sample code for a given driver component should be used for !!
  10. * !! development purposes. !!
  11. * !! !!
  12. * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  13. *
  14. * Module Name: glddtk.h
  15. *
  16. * Content:
  17. *
  18. * Copyright (c) 1994-1999 3Dlabs Inc. Ltd. All rights reserved.
  19. * Copyright (c) 1995-2003 Microsoft Corporation. All rights reserved.
  20. \*****************************************************************************/
  21. #ifndef __DDSAMPTK_INCLUDED__
  22. #define __DDSAMPTK_INCLUDED__
  23. #pragma warning( disable: 4704)
  24. #define P3R3DX_DLLNAME "p3r3dx.dll"
  25. #define MAX_TEXTURE_FORMAT 35
  26. // The Maximum possible screen widths for the cards
  27. #define MAX_GLINT_PP_WIDTH 8192
  28. #define MAX_PERMEDIA_PP_WIDTH 2048
  29. // For comparing runtime versions
  30. #define DX5_RUNTIME 0x00000500l
  31. #define DX6_RUNTIME 0x00000600l
  32. #define DX7_RUNTIME 0x00000700l
  33. #ifdef W95_DDRAW
  34. // Videoport needs to live in pThisDisplay, it may
  35. // be on a second display card, etc.
  36. #define MAX_AUTOFLIP_SURFACES 3
  37. typedef struct tagPERMEDIA_VIDEOPORT
  38. {
  39. // The ID of this video port
  40. DWORD dwPortID;
  41. // Permedia VideoPort supports up to
  42. // 3 autoflipping surfaces
  43. DWORD dwNumSurfaces;
  44. LPDDRAWI_DDRAWSURFACE_LCL lpSurf[MAX_AUTOFLIP_SURFACES];
  45. DWORD dwSurfacePointer[MAX_AUTOFLIP_SURFACES];
  46. // How are the signals setup?
  47. DWORD dwStreamAFlags;
  48. DWORD dwStreamBFlags;
  49. // Height of the VideoBlanking interval
  50. DWORD dwVBIHeight;
  51. DWORD dwFieldHeight;
  52. DWORD dwFieldWidth;
  53. // Where are we currently reading from?
  54. DWORD dwCurrentHostFrame;
  55. // Is the video playing?
  56. DWORD bActive;
  57. // A mutex to take ownership of the videoport.
  58. DWORD dwMutexA;
  59. // For VP error checking
  60. DWORD bResetStatus;
  61. DWORD dwStartLine;
  62. DWORD dwStartIndex;
  63. DWORD dwStartLineTime;
  64. DWORD dwErrorCount;
  65. // Is the VideoPort active?
  66. DWORD bCreated;
  67. } PERMEDIA_VIDEOPORT;
  68. #endif // W95_DDRAW
  69. // Enumerated type for the style of buffer that is being used.
  70. typedef enum tageBufferType
  71. {
  72. COMMAND_BUFFER = 0,
  73. VERTEX_BUFFER = 1,
  74. FORCE_DWORD_BUFFERTYPE_SIZE = 0xFFFFFFFF
  75. } eBufferType;
  76. typedef struct tagDRVRECT
  77. {
  78. #ifndef WIN32
  79. DWORD left;
  80. DWORD top;
  81. DWORD right;
  82. DWORD bottom;
  83. #else
  84. LONG left;
  85. LONG top;
  86. LONG right;
  87. LONG bottom;
  88. #endif
  89. } DRVRECT;
  90. typedef struct tagOVERLAYDATA
  91. {
  92. DRVRECT rcSrc;
  93. DRVRECT rcDest;
  94. #ifndef WIN32
  95. DWORD dwOverlayPointer;
  96. #else
  97. FLATPTR pCurrentOverlay;
  98. #endif
  99. DWORD dwCurrentVideoBuffer;
  100. DWORD dwVisibleOverlays;
  101. } OVERLAYDATA;
  102. typedef struct tagP3VERTEXBUFFERINFO
  103. {
  104. DWORD dwSequenceID;
  105. DWORD bInUse;
  106. eBufferType BufferType;
  107. DWORD dwSize;
  108. struct tagP3VERTEXBUFFERINFO* pNext;
  109. struct tagP3VERTEXBUFFERINFO* pPrev;
  110. } P3_VERTEXBUFFERINFO;
  111. typedef struct
  112. {
  113. // Where we flipped from
  114. FLATPTR fpFlipFrom;
  115. // An ID for the flip
  116. DWORD dwFlipID;
  117. } FLIPRECORD;
  118. typedef FLIPRECORD FAR *LPFLIPRECORD;
  119. typedef struct _GlintDMABuffer
  120. {
  121. DWORD dwBuffSize;
  122. DWORD dwBuffPhys;
  123. ULONG_PTR dwBuffVirt;
  124. DWORD dwSubBuff;
  125. } GLDMABUFF, *LPGLDMABUFF;
  126. // Function prototype to fire off a DMA operation
  127. typedef DWORD (WINAPI *__StartDMA)(struct tagThunkedData* pThisDisplay,
  128. DWORD dwContext, DWORD dwSize,
  129. DWORD dwPhys, ULONG_PTR dwVirt,
  130. DWORD dwEvent);
  131. typedef struct tagThunkedData
  132. {
  133. ULONG_PTR control;
  134. DWORD ramdac;
  135. DWORD lpMMReg;
  136. // The Mini VDD's DevNode
  137. DWORD dwDevNode;
  138. // Virt. Address of the start of screen memory
  139. DWORD dwScreenFlatAddr;
  140. // Virt. Address of the start of LB memory
  141. DWORD dwLocalBuffer;
  142. // Screen settings
  143. DWORD dwScreenWidth;
  144. DWORD dwScreenHeight;
  145. DWORD cxMemory;
  146. DWORD cyMemory;
  147. // A lookup table for all the Partial Products
  148. DWORD PPCodes[(MAX_GLINT_PP_WIDTH / 32) + 1];
  149. // Memory to remove from the card (for debugging)
  150. DWORD dwSubMemory;
  151. // Virtual address of start of screen
  152. DWORD dwScreenStart;
  153. DWORD bPixShift;
  154. DWORD bBppShift;
  155. DWORD dwBppMask;
  156. // Reset flag
  157. DWORD bResetMode; // Has the mode been changed?
  158. DWORD bStartOfDay; // Has the driver just been initialised?
  159. DWORD bVFWEnabled; // Is Video For windows currently enabled?
  160. DWORD bDDHeapManager; // Using the Linear Heap manager?
  161. DWORD dwSetupThisDisplay; // Has this display been intialised (a ref count)?
  162. DWORD dwBackBufferCount; // How many back buffers have we handed out on TX at 640x400?
  163. DWORD EntriesLeft; // Number of entries left in FIFO (for debugging)
  164. DWORD DMAEntriesLeft; // Number of entries left in DMA buffer (for debugging)
  165. DWORD bFlippedSurface; // Has this card had a page flip?
  166. DWORD ModeChangeCount;
  167. // Current pixel format of display
  168. DDPIXELFORMAT ddpfDisplay;
  169. // Shared Display driver memory pointer
  170. LPGLINTINFO pGLInfo;
  171. #ifndef WIN32
  172. DWORD pGlint;
  173. #else
  174. // Pointer to the actual glint registers.
  175. FPGLREG pGlint;
  176. #endif
  177. // Is this card capable of AGP texturing?
  178. DWORD bCanAGP;
  179. // Flag to tell stretchblits whether to filter.
  180. DWORD bFilterStretches;
  181. // Overlay data
  182. // This data has to be available at any times, because we are emulating it.
  183. // Only one overlay at a time supported
  184. DWORD bOverlayVisible; // TRUE if the overlay is visible.
  185. DWORD OverlayDstRectL;
  186. DWORD OverlayDstRectR;
  187. DWORD OverlayDstRectT;
  188. DWORD OverlayDstRectB; // where the overlay is on screen
  189. DWORD OverlaySrcRectL;
  190. DWORD OverlaySrcRectR;
  191. DWORD OverlaySrcRectT;
  192. DWORD OverlaySrcRectB; // which bit of the overlay is visible
  193. ULONG_PTR OverlayDstSurfLcl; // the surface overlaid (usually the primary)
  194. ULONG_PTR OverlaySrcSurfLcl; // the overlay surface
  195. DWORD OverlayDstColourKey; // the overlaid surface's written-to colour key
  196. DWORD OverlaySrcColourKey; // the overlay's transparent colour key
  197. ULONG_PTR OverlayClipRgnMem; // buffer to hold a temporary clip region
  198. DWORD OverlayClipRgnMemSize; // ...the size of the buffer
  199. DWORD OverlayUpdateCountdown; // how many flips/unlocks before an update is done.
  200. DWORD bOverlayFlippedThisVbl; // TRUE if overlay was flipped this VBL.
  201. DWORD bOverlayUpdatedThisVbl; // TRUE if overlay was updated (not including flips) this VBL.
  202. struct {
  203. ULONG_PTR VidMem;
  204. DWORD Pitch;
  205. } OverlayTempSurf; // The temporary video buffer used by the overlay.
  206. OVERLAYDATA P3Overlay;
  207. DWORD dwOverlayFiltering; // TRUE if the overlay is filtering.
  208. DWORD bOverlayPixelDouble; // TRUE if the screen is pixel-doubled.
  209. #if W95_DDRAW
  210. // Colour control variables.
  211. DWORD ColConBrightness; // Brightness 0->10000, default 0 (ish)
  212. DWORD ColConContrast; // Contrast 0->20000, default 10000
  213. DWORD ColConGamma; // Gamma 1->500, default 100
  214. #endif // W95_DDRAW
  215. #if DX7_VIDMEM_VB
  216. // DrawPrim temporary index buffer.
  217. ULONG_PTR DrawPrimIndexBufferMem; // Pointer to the buffer.
  218. DWORD DrawPrimIndexBufferMemSize; // Size of the buffer.
  219. // DrawPrim temporary vertex buffer.
  220. ULONG_PTR DrawPrimVertexBufferMem; // Pointer to the buffer.
  221. DWORD DrawPrimVertexBufferMemSize; // Size of the buffer.
  222. #endif // DX7_VIDMEM_VB
  223. // Current RenderID.
  224. DWORD dwRenderID;
  225. // TRUE if the chip's render ID is valid.
  226. DWORD bRenderIDValid;
  227. // The RenderIDs of the last two Flips to be
  228. // put into the DMA/FIFO/pipeline. See Flip32 for further info.
  229. DWORD dwLastFlipRenderID;
  230. DWORD dwLastFlipRenderID2;
  231. // DirectDraw DMA variables
  232. __StartDMA StartDMA; // Pointer to the StartDMA function
  233. DWORD PartitionSize;
  234. DWORD BufferLocked;
  235. GLDMABUFF DMAInfo;
  236. DWORD b2D_FIFOS; // DDRAW using FIFO's?
  237. // These buffers hold counts that the driver is using
  238. // to keep track of operations in the chip
  239. #ifdef WIN32
  240. P3_VERTEXBUFFERINFO* pRootCommandBuffer;
  241. P3_VERTEXBUFFERINFO* pRootVertexBuffer;
  242. #else
  243. DWORD pRootCommandBuffer;
  244. DWORD pRootVertexBuffer;
  245. #endif
  246. DWORD dwCurrentSequenceID;
  247. // HINSTANCE of p3r3dx.dll
  248. HINSTANCE hInstance;
  249. // DirectDraw callbacks
  250. DDHAL_DDCALLBACKS DDHALCallbacks;
  251. DDHAL_DDSURFACECALLBACKS DDSurfCallbacks;
  252. // D3D Callbacks
  253. ULONG_PTR lpD3DGlobalDriverData;
  254. ULONG_PTR lpD3DHALCallbacks;
  255. ULONG_PTR lpD3DBufCallbacks;
  256. #if W95_DDRAW
  257. DDHAL_DDEXEBUFCALLBACKS DDExeBufCallbacks;
  258. #endif
  259. DWORD dwNumTextureFormats;
  260. DDSURFACEDESC TextureFormats[MAX_TEXTURE_FORMAT];
  261. DWORD dwDXVersion;
  262. // These have to live here, as we could be running on 2 different cards
  263. // on two different displays...!
  264. DWORD pD3DDriverData16;
  265. DWORD pD3DHALCallbacks16;
  266. DWORD pD3DHALExecuteCallbacks16;
  267. ULONG_PTR pD3DDriverData32;
  268. ULONG_PTR pD3DHALCallbacks32;
  269. ULONG_PTR pD3DHALExecuteCallbacks32;
  270. // A linear allocator block for the local video heap
  271. LinearAllocatorInfo LocalVideoHeap0Info;
  272. LinearAllocatorInfo CachedCommandHeapInfo;
  273. LinearAllocatorInfo CachedVertexHeapInfo;
  274. DWORD dwGARTLin; // Linear address of Base of AGP Memory
  275. DWORD dwGARTDev; // High Linear address of Base of AGP Memory
  276. DWORD dwGARTLinBase; // The base address passed into the updatenonlocalvidmem call
  277. DWORD dwGARTDevBase; // The base address passsed in
  278. #if W95_DDRAW
  279. // The Videoport for this display
  280. PERMEDIA_VIDEOPORT VidPort;
  281. #endif
  282. #if WNT_DDRAW
  283. #if (_WIN32_WINNT >= 0x500)
  284. PFND3DPARSEUNKNOWNCOMMAND pD3DParseUnknownCommand;
  285. #else
  286. DWORD pD3DParseUnknownCommand;
  287. #endif
  288. #else // WNT_DDRAW
  289. // DirectX 6 Support
  290. #ifdef WIN32
  291. //pointer to vertex buffer unknown command processing function
  292. PFND3DPARSEUNKNOWNCOMMAND pD3DParseUnknownCommand;
  293. #else
  294. DWORD pD3DParseUnknownCommand; // ? Safe ?
  295. #endif // WIN32
  296. #endif // WNT_DDRAW
  297. #if WNT_DDRAW
  298. PPDEV ppdev; // Pointer to the NT globals
  299. volatile DWORD * VBlankStatusPtr; // Pointer to VBlank status word (shared with miniport)
  300. volatile DWORD * bOverlayEnabled; // Pointer to overlay enabled flag (shared with miniport)
  301. volatile DWORD * bVBLANKUpdateOverlay; // Pointer to overlay update flag
  302. volatile DWORD * VBLANKUpdateOverlayWidth; // Pointer to overlay width (shared with miniport)
  303. volatile DWORD * VBLANKUpdateOverlayHeight; // Pointer to overlay height (shared with miniport)
  304. #endif // WNT_DDRAW
  305. #ifdef WIN32
  306. HashTable* pDirectDrawLocalsHashTable;
  307. HashTable* pMocompHashTable;
  308. #else
  309. DWORD pDirectDrawLocalsHashTable;
  310. DWORD pMocompHashTable;
  311. #endif
  312. #ifdef WNT_DDRAW
  313. DWORD pAGPHeap;
  314. #else
  315. #ifdef WIN32
  316. // Pointer to AGP heap, used for logical texturing
  317. LPVIDMEM pAGPHeap;
  318. #endif
  319. #endif
  320. FLIPRECORD flipRecord;
  321. DWORD dwFlushLogfile;
  322. // HAL info structure. THIS MUST BE THE LAST THING IN THIS STRUCTURE
  323. DDHALINFO ddhi32;
  324. } P3_THUNKEDDATA;
  325. #endif