Source code of Windows XP (NT5)
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.

1375 lines
39 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: mcd.c
  3. *
  4. * Main file for the Matrox Millenium OpenGL MCD driver. This file contains
  5. * the entry points needed for an MCD driver.
  6. *
  7. * Copyright (c) 1996 Microsoft Corporation
  8. \**************************************************************************/
  9. #include "precomp.h"
  10. #include <excpt.h>
  11. #include "mcdhw.h"
  12. #include "mcdutil.h"
  13. #include "mcdmath.h"
  14. #define FAIL_ALL_DRAWING 0
  15. #define FORCE_SYNC 0
  16. #define TOTAL_PIXEL_FORMATS (2 * 2) // double-buffers * z-buffers
  17. // Base color pixel formats
  18. static DRVPIXELFORMAT drvFormats[] = { {8, 3, 3, 2, 0, 5, 2, 0, 0},
  19. {16, 5, 5, 5, 0, 10, 5, 0, 0},
  20. {16, 5, 6, 5, 0, 11, 5, 0, 0},
  21. {24, 8, 8, 8, 0, 16, 8, 0, 0},
  22. {32, 8, 8, 8, 0, 16, 8, 0, 0},
  23. };
  24. LONG MCDrvDescribePixelFormat(MCDSURFACE *pMCDSurface, LONG iPixelFormat,
  25. ULONG nBytes, MCDPIXELFORMAT *pMCDPixelFormat,
  26. ULONG flags)
  27. {
  28. BOOL zEnabled;
  29. BOOL doubleBufferEnabled;
  30. DRVPIXELFORMAT *pDrvPixelFormat;
  31. PDEV *ppdev = (PDEV *)pMCDSurface->pso->dhpdev;
  32. // MCDBG_PRINT("MCDrvDescribePixelFormat");
  33. if (!pMCDPixelFormat) {
  34. // We don't support 24bpp or the older MGA:
  35. if ((ppdev->ulBoardId != MGA_STORM) ||
  36. (ppdev->iBitmapFormat == BMF_24BPP))
  37. return 0;
  38. return TOTAL_PIXEL_FORMATS;
  39. }
  40. if (nBytes < sizeof(MCDPIXELFORMAT))
  41. return 0;
  42. if (iPixelFormat > TOTAL_PIXEL_FORMATS)
  43. return 0;
  44. // We don't support the older MGA in this driver:
  45. if (ppdev->ulBoardId != MGA_STORM)
  46. return 0;
  47. iPixelFormat--;
  48. zEnabled = iPixelFormat >= (TOTAL_PIXEL_FORMATS / 2);
  49. doubleBufferEnabled = (iPixelFormat % (TOTAL_PIXEL_FORMATS / 2) ) >=
  50. (TOTAL_PIXEL_FORMATS / 4);
  51. pMCDPixelFormat->nSize = sizeof(MCDPIXELFORMAT);
  52. pMCDPixelFormat->dwFlags = PFD_SWAP_COPY;
  53. if (doubleBufferEnabled)
  54. pMCDPixelFormat->dwFlags |= PFD_DOUBLEBUFFER;
  55. pMCDPixelFormat->iPixelType = PFD_TYPE_RGBA;
  56. switch (ppdev->iBitmapFormat) {
  57. default:
  58. case BMF_8BPP:
  59. pDrvPixelFormat = &drvFormats[0];
  60. pMCDPixelFormat->dwFlags |= (PFD_NEED_SYSTEM_PALETTE | PFD_NEED_PALETTE);
  61. break;
  62. case BMF_16BPP:
  63. if (ppdev->flGreen != 0x7e0) // not 565
  64. pDrvPixelFormat = &drvFormats[1];
  65. else
  66. pDrvPixelFormat = &drvFormats[2];
  67. break;
  68. case BMF_24BPP: // The Millenium doesn't do 3D at 24bpp!
  69. return 0;
  70. case BMF_32BPP:
  71. pDrvPixelFormat = &drvFormats[4];
  72. break;
  73. }
  74. pMCDPixelFormat->cColorBits = pDrvPixelFormat->cColorBits;
  75. pMCDPixelFormat->cRedBits = pDrvPixelFormat->rBits;
  76. pMCDPixelFormat->cGreenBits = pDrvPixelFormat->gBits;
  77. pMCDPixelFormat->cBlueBits = pDrvPixelFormat->bBits;
  78. pMCDPixelFormat->cAlphaBits = pDrvPixelFormat->aBits;
  79. pMCDPixelFormat->cRedShift = pDrvPixelFormat->rShift;
  80. pMCDPixelFormat->cGreenShift = pDrvPixelFormat->gShift;
  81. pMCDPixelFormat->cBlueShift = pDrvPixelFormat->bShift;
  82. pMCDPixelFormat->cAlphaShift = pDrvPixelFormat->aShift;
  83. if (zEnabled)
  84. {
  85. pMCDPixelFormat->cDepthBits = 16;
  86. pMCDPixelFormat->cDepthBufferBits = 16;
  87. pMCDPixelFormat->cDepthShift = 16;
  88. }
  89. else
  90. {
  91. pMCDPixelFormat->cDepthBits = 0;
  92. pMCDPixelFormat->cDepthBufferBits = 0;
  93. pMCDPixelFormat->cDepthShift = 0;
  94. }
  95. // MGA does not support stencil; generic will supply a software
  96. // implementation as necessary.
  97. pMCDPixelFormat->cStencilBits = 0;
  98. pMCDPixelFormat->cOverlayPlanes = 0;
  99. pMCDPixelFormat->cUnderlayPlanes = 0;
  100. pMCDPixelFormat->dwTransparentColor = 0;
  101. return TOTAL_PIXEL_FORMATS;
  102. }
  103. BOOL MCDrvDescribeLayerPlane(MCDSURFACE *pMCDSurface,
  104. LONG iPixelFormat, LONG iLayerPlane,
  105. ULONG nBytes, MCDLAYERPLANE *pMCDLayerPlane,
  106. ULONG flags)
  107. {
  108. //MCDBG_PRINT("MCDrvDescribeLayerPlane");
  109. return FALSE;
  110. }
  111. LONG MCDrvSetLayerPalette(MCDSURFACE *pMCDSurface, LONG iLayerPlane,
  112. BOOL bRealize, LONG cEntries, COLORREF *pcr)
  113. {
  114. //MCDBG_PRINT("MCDrvSetLayerPalette");
  115. return 0;
  116. }
  117. BOOL MCDrvInfo(MCDSURFACE *pMCDSurface, MCDDRIVERINFO *pMCDDriverInfo)
  118. {
  119. // MCDBG_PRINT("MCDrvInfo");
  120. pMCDDriverInfo->verMajor = MCD_VER_MAJOR;
  121. pMCDDriverInfo->verMinor = MCD_VER_MINOR;
  122. pMCDDriverInfo->verDriver = 0x10000;
  123. strcpy(pMCDDriverInfo->idStr, "Matrox STORM (Microsoft)");
  124. pMCDDriverInfo->drvMemFlags = 0;
  125. pMCDDriverInfo->drvBatchMemSizeMax = 128000;
  126. return TRUE;
  127. }
  128. ULONG MCDrvCreateContext(MCDSURFACE *pMCDSurface, MCDRC *pMCDRc,
  129. MCDRCINFO *pRcInfo)
  130. {
  131. DEVRC *pRc;
  132. MCDWINDOW *pMCDWnd = pMCDSurface->pWnd;
  133. DEVWND *pDevWnd;
  134. PDEV *ppdev = (PDEV *)pMCDSurface->pso->dhpdev;
  135. DRVPIXELFORMAT *pDrvPixelFormat;
  136. MCDVERTEX *pv;
  137. BOOL zEnabled;
  138. BOOL doubleBufferEnabled;
  139. ULONG i, maxVi;
  140. // MCDBG_PRINT("MCDrvCreateContext");
  141. // We only support window surfaces:
  142. if (! (pMCDSurface->surfaceFlags & MCDSURFACE_HWND) )
  143. return FALSE;
  144. // We don't support the older MGA in this driver:
  145. if (ppdev->ulBoardId != MGA_STORM)
  146. return FALSE;
  147. if ((pMCDRc->iPixelFormat > TOTAL_PIXEL_FORMATS) ||
  148. (pMCDRc->iPixelFormat < 0)) {
  149. MCDBG_PRINT("MCDrvCreateContext: bad pixel format");
  150. return FALSE;
  151. }
  152. // We don't support overlay planes:
  153. if (pMCDRc->iLayerPlane)
  154. return FALSE;
  155. pRc = pMCDRc->pvUser = (DEVRC *)MCDAlloc(sizeof(DEVRC));
  156. if (!pRc) {
  157. MCDBG_PRINT("MCDrvCreateContext: couldn't allocate DEVRC");
  158. return FALSE;
  159. }
  160. zEnabled = (pMCDRc->iPixelFormat - 1) >= (TOTAL_PIXEL_FORMATS / 2);
  161. doubleBufferEnabled = ((pMCDRc->iPixelFormat - 1) % (TOTAL_PIXEL_FORMATS / 2) ) >=
  162. (TOTAL_PIXEL_FORMATS / 4);
  163. pRc->zBufEnabled = zEnabled;
  164. pRc->backBufEnabled = doubleBufferEnabled;
  165. switch (ppdev->iBitmapFormat) {
  166. default:
  167. case BMF_8BPP:
  168. pDrvPixelFormat = &drvFormats[0];
  169. pRc->hwBpp = 1;
  170. break;
  171. case BMF_16BPP:
  172. if (ppdev->flGreen != 0x7e0) // not 565
  173. pDrvPixelFormat = &drvFormats[1];
  174. else
  175. pDrvPixelFormat = &drvFormats[2];
  176. pRc->hwBpp = 2;
  177. break;
  178. case BMF_24BPP: // The Millenium doesn't do 3D at 24bpp!
  179. MCDFree(pMCDRc->pvUser);
  180. pMCDRc->pvUser = NULL;
  181. MCDBG_PRINT("MCDrvCreateContext: device doesn't support 24 bpp");
  182. return FALSE;
  183. case BMF_32BPP:
  184. pDrvPixelFormat = &drvFormats[4];
  185. pRc->hwBpp = 4;
  186. break;
  187. }
  188. pRc->pixelFormat = *pDrvPixelFormat;
  189. // If we're not yet tracking this window, allocate the per-window DEVWND
  190. // structure for maintaining per-window info such as front/back/z buffer
  191. // resources:
  192. if (!pMCDWnd->pvUser) {
  193. pDevWnd = pMCDWnd->pvUser = (DEVWND *)MCDAlloc(sizeof(DEVWND));
  194. if (!pDevWnd) {
  195. MCDFree(pMCDRc->pvUser);
  196. pMCDRc->pvUser = NULL;
  197. MCDBG_PRINT("MCDrvCreateContext: couldn't allocate DEVWND");
  198. return FALSE;
  199. }
  200. pDevWnd->createFlags = pMCDRc->createFlags;
  201. pDevWnd->iPixelFormat = pMCDRc->iPixelFormat;
  202. pDevWnd->dispUnique = GetDisplayUniqueness(ppdev);
  203. } else {
  204. // We already have a per-window DEVWND structure tracking this window.
  205. // In this case, do a sanity-check on the pixel format for this
  206. // context, since a window's pixel format can not changed once it has
  207. // set (by the first context bound to the window). So, if the pixel
  208. // format for the incoming context doesn't match the current pixel
  209. // format for the window, we have to fail context creation:
  210. pDevWnd = pMCDWnd->pvUser;
  211. if (pDevWnd->iPixelFormat != pMCDRc->iPixelFormat) {
  212. MCDFree(pMCDRc->pvUser);
  213. pMCDRc->pvUser = NULL;
  214. MCDBG_PRINT("MCDrvCreateContext: mismatched pixel formats, window = %d, context = %d",
  215. pDevWnd->iPixelFormat, pMCDRc->iPixelFormat);
  216. return FALSE;
  217. }
  218. }
  219. pRc->pEnumClip = pMCDSurface->pWnd->pClip;
  220. // Set up our color scale values so that color components are
  221. // normalized to 0..7fffff
  222. // We also need to make sure we don't fault due to bad FL data as well...
  223. try {
  224. if (pRcInfo->redScale != (MCDFLOAT)0.0)
  225. pRc->rScale = (MCDFLOAT)(0x7fffff) / pRcInfo->redScale;
  226. else
  227. pRc->rScale = (MCDFLOAT)0.0;
  228. if (pRcInfo->greenScale != (MCDFLOAT)0.0)
  229. pRc->gScale = (MCDFLOAT)(0x7fffff) / pRcInfo->greenScale;
  230. else
  231. pRc->gScale = (MCDFLOAT)0.0;
  232. if (pRcInfo->blueScale != (MCDFLOAT)0.0)
  233. pRc->bScale = (MCDFLOAT)(0x7fffff) / pRcInfo->blueScale;
  234. else
  235. pRc->bScale = (MCDFLOAT)0.0;
  236. // Normalize alpha to 0..ff0000
  237. if (pRcInfo->alphaScale != (MCDFLOAT)0.0)
  238. pRc->aScale = (MCDFLOAT)(0xff0000) / pRcInfo->alphaScale;
  239. else
  240. pRc->aScale = (MCDFLOAT)0.0;
  241. } except (EXCEPTION_EXECUTE_HANDLER) {
  242. MCDBG_PRINT("!!Exception in MCDrvCreateContext!!");
  243. return FALSE;
  244. }
  245. pRc->zScale = (MCDFLOAT)32767.0;
  246. pRc->pickNeeded = TRUE; // We'll definitely need to re-pick
  247. // our rendering functions
  248. pRc->bRGBMode = TRUE; // We only support RGB mode
  249. pRc->zero = __MCDZERO;
  250. // Initialize the pColor pointer in the clip buffer:
  251. for (i = 0, pv = &pRc->clipTemp[0],
  252. maxVi = sizeof(pRc->clipTemp) / sizeof(MCDVERTEX);
  253. i < maxVi; i++, pv++) {
  254. pv->pColor = &pv->colors[__MCD_FRONTFACE];
  255. }
  256. // Set up those rendering functions which are state-invariant:
  257. pRc->clipLine = __MCDClipLine;
  258. pRc->clipTri = __MCDClipTriangle;
  259. pRc->clipPoly = __MCDClipPolygon;
  260. pRc->doClippedPoly = __MCDDoClippedPolygon;
  261. pRc->beginPointDrawing = __MCDPointBegin;
  262. pRc->beginLineDrawing = __MCDLineBegin;
  263. pRc->endLineDrawing = __MCDLineEnd;
  264. pRc->viewportXAdjust = pRcInfo->viewportXAdjust;
  265. pRc->viewportYAdjust = pRcInfo->viewportYAdjust;
  266. #ifdef TEST_REQ_FLAGS
  267. pRcInfo->requestFlags = MCDRCINFO_NOVIEWPORTADJUST |
  268. MCDRCINFO_Y_LOWER_LEFT |
  269. MCDRCINFO_DEVCOLORSCALE |
  270. MCDRCINFO_DEVZSCALE;
  271. pRcInfo->redScale = (MCDFLOAT)1.0;
  272. pRcInfo->greenScale = (MCDFLOAT)1.0;
  273. pRcInfo->blueScale = (MCDFLOAT)1.0;
  274. pRcInfo->alphaScale = (MCDFLOAT)1.0;
  275. pRcInfo->zScale = 0.99991;
  276. #endif
  277. return TRUE;
  278. }
  279. ULONG MCDrvDeleteContext(MCDRC *pRc, DHPDEV dhpdev)
  280. {
  281. // MCDBG_PRINT("MCDrvDeleteContext");
  282. if (pRc->pvUser) {
  283. MCDFree(pRc->pvUser);
  284. pRc->pvUser = NULL;
  285. }
  286. return (ULONG)TRUE;
  287. }
  288. ULONG MCDrvAllocBuffers(MCDSURFACE *pMCDSurface, MCDRC *pMCDRc)
  289. {
  290. DEVRC *pRc = (DEVRC *)pMCDRc->pvUser;
  291. MCDWINDOW *pMCDWnd = pMCDSurface->pWnd;
  292. DEVWND *pDevWnd = (DEVWND *)(pMCDSurface->pWnd->pvUser);
  293. BOOL bZBuffer = (pDevWnd->pohZBuffer != NULL);
  294. BOOL bBackBuffer = (pDevWnd->pohBackBuffer != NULL);
  295. // MCDBG_PRINT("MCDrvAllocBuffers");
  296. // Reject the call if we've already done an allocation for this window:
  297. if ((bZBuffer || bBackBuffer) &&
  298. ((DEVWND *)pMCDWnd->pvUser)->dispUnique == GetDisplayUniqueness((PDEV *)pMCDSurface->pso->dhpdev)) {
  299. // MCDBG_PRINT("MCDrvAllocBuffer: warning-attemp to allocate buffers \
  300. //without a matching free");
  301. return (bZBuffer == pRc->zBufEnabled) &&
  302. (bBackBuffer == pRc->backBufEnabled);
  303. }
  304. // Update the display resolution uniqueness for this window:
  305. ((DEVWND *)pMCDWnd->pvUser)->dispUnique = GetDisplayUniqueness((PDEV *)pMCDSurface->pso->dhpdev);
  306. return (ULONG)HWAllocResources(pMCDSurface->pWnd, pMCDSurface->pso,
  307. pRc->zBufEnabled, pRc->backBufEnabled);
  308. }
  309. ULONG MCDrvGetBuffers(MCDSURFACE *pMCDSurface, MCDRC *pMCDRc,
  310. MCDBUFFERS *pMCDBuffers)
  311. {
  312. MCDWINDOW *pMCDWnd = pMCDSurface->pWnd;
  313. DEVWND *pDevWnd = (DEVWND *)(pMCDSurface->pWnd->pvUser);
  314. PDEV *ppdev = (PDEV *)pMCDSurface->pso->dhpdev;
  315. // MCDBG_PRINT("MCDrvGetBuffers");
  316. if (pMCDRc) {
  317. MCD_CHECK_BUFFERS_VALID(pMCDSurface, (DEVRC *)pMCDRc->pvUser, FALSE);
  318. } else {
  319. MCD_CHECK_DEVWND(pMCDSurface, pDevWnd, FALSE);
  320. }
  321. pMCDBuffers->mcdFrontBuf.bufFlags = MCDBUF_ENABLED;
  322. pMCDBuffers->mcdFrontBuf.bufOffset =
  323. (pMCDWnd->clientRect.top * ppdev->lDelta) +
  324. (pMCDWnd->clientRect.left * ppdev->cjHwPel);
  325. pMCDBuffers->mcdFrontBuf.bufStride = ppdev->lDelta;
  326. if (pDevWnd->bValidBackBuffer) {
  327. pMCDBuffers->mcdBackBuf.bufFlags = MCDBUF_ENABLED;
  328. if ((ppdev->cDoubleBufferRef == 1) || (pMCDWnd->pClip->c == 1))
  329. pMCDBuffers->mcdBackBuf.bufFlags |= MCDBUF_NOCLIP;
  330. } else {
  331. pMCDBuffers->mcdBackBuf.bufFlags = 0;
  332. }
  333. if (ppdev->pohBackBuffer == pDevWnd->pohBackBuffer) {
  334. pMCDBuffers->mcdBackBuf.bufOffset =
  335. (pMCDWnd->clientRect.top * ppdev->lDelta) +
  336. (pMCDWnd->clientRect.left * ppdev->cjHwPel) +
  337. pDevWnd->backBufferOffset;
  338. } else {
  339. pMCDBuffers->mcdBackBuf.bufOffset =
  340. (pMCDWnd->clientRect.left * ppdev->cjHwPel) +
  341. pDevWnd->backBufferOffset;
  342. }
  343. pMCDBuffers->mcdBackBuf.bufStride = ppdev->lDelta;
  344. if (pDevWnd->bValidZBuffer) {
  345. pMCDBuffers->mcdDepthBuf.bufFlags = MCDBUF_ENABLED;
  346. if ((ppdev->cZBufferRef == 1) || (pMCDWnd->pClip->c == 1))
  347. pMCDBuffers->mcdDepthBuf.bufFlags |= MCDBUF_NOCLIP;
  348. } else {
  349. pMCDBuffers->mcdDepthBuf.bufFlags = 0;
  350. }
  351. if (ppdev->pohZBuffer == pDevWnd->pohZBuffer) {
  352. pMCDBuffers->mcdDepthBuf.bufOffset =
  353. ((pMCDWnd->clientRect.top * ppdev->cxMemory) +
  354. pMCDWnd->clientRect.left) * 2 +
  355. pDevWnd->zBufferOffset;
  356. } else {
  357. pMCDBuffers->mcdDepthBuf.bufOffset =
  358. (pMCDWnd->clientRect.left * 2) + pDevWnd->zBufferOffset;
  359. }
  360. // The pointer to the start of the frame buffer is adjusted for ulYDstOrg,
  361. // so we have to redo that adjustment for the depth buffer:
  362. if (ppdev->ulYDstOrg) {
  363. pMCDBuffers->mcdDepthBuf.bufOffset +=
  364. (ppdev->ulYDstOrg * 2) - (ppdev->ulYDstOrg * ppdev->cjHwPel);
  365. }
  366. pMCDBuffers->mcdDepthBuf.bufStride = ppdev->cxMemory * 2;
  367. return (ULONG)TRUE;
  368. }
  369. ULONG MCDrvCreateMem(MCDSURFACE *pMCDSurface, MCDMEM *pMCDMem)
  370. {
  371. // MCDBG_PRINT("MCDrvCreateMem");
  372. return (ULONG)TRUE;
  373. }
  374. ULONG MCDrvDeleteMem(MCDMEM *pMCDMem, DHPDEV dhpdev)
  375. {
  376. // MCDBG_PRINT("MCDrvDeleteMem");
  377. return (ULONG)TRUE;
  378. }
  379. ULONG_PTR MCDrvDraw(MCDSURFACE *pMCDSurface, MCDRC *pMCDRc, MCDMEM *prxExecMem,
  380. UCHAR *pStart, UCHAR *pEnd)
  381. {
  382. MCDCOMMAND *pCmd = (MCDCOMMAND *)pStart;
  383. MCDCOMMAND *pCmdNext;
  384. DEVRC *pRc = (DEVRC *)pMCDRc->pvUser;
  385. DEVWND *pDevWnd = (DEVWND *)(pMCDSurface->pWnd->pvUser);
  386. CHOP_ROUND_ON();
  387. #if TEST_3D_NO_DRAW
  388. CHOP_ROUND_OFF();
  389. return (ULONG)0;
  390. #endif
  391. // MCDBG_PRINT("MCDrvDraw");
  392. // Make sure we have both a valid RC and window structure:
  393. if (!pRc || !pDevWnd)
  394. goto DrawExit;
  395. pRc->ppdev = (PDEV *)pMCDSurface->pso->dhpdev;
  396. #if FAIL_ALL_DRAWING
  397. goto DrawExit;
  398. #endif
  399. //
  400. // If the resolution has changed and we have not yet updated our
  401. // buffers, fail the call gracefully since the client won't be
  402. // able to perform any software simulations at this point either.
  403. // This applies to any of the other drawing functions as well (such
  404. // as spans and clears).
  405. //
  406. if (pDevWnd->dispUnique != GetDisplayUniqueness(pRc->ppdev)) {
  407. MCDBG_PRINT("MCDrvDraw: invalid (changed) resolution");
  408. CHOP_ROUND_OFF();
  409. return (ULONG)0;
  410. }
  411. if ((pRc->zBufEnabled && !pDevWnd->bValidZBuffer) ||
  412. (pRc->backBufEnabled && !pDevWnd->bValidBackBuffer)) {
  413. MCDBG_PRINT("MCDrvDraw has invalid buffers");
  414. goto DrawExit;
  415. }
  416. // re-pick the rendering functions if we've have a state change:
  417. if (pRc->pickNeeded) {
  418. __MCDPickRenderingFuncs(pRc, pDevWnd);
  419. __MCDPickClipFuncs(pRc);
  420. pRc->pickNeeded = FALSE;
  421. }
  422. // If we're completely clipped, return success:
  423. pRc->pEnumClip = pMCDSurface->pWnd->pClip;
  424. if (!pRc->pEnumClip->c) {
  425. CHOP_ROUND_OFF();
  426. return (ULONG)0;
  427. }
  428. // return here if we can't draw any primitives:
  429. if (pRc->allPrimFail) {
  430. goto DrawExit;
  431. }
  432. // Set these up in the device's RC so we can just pass a single pointer
  433. // to do everything:
  434. pRc->pMCDSurface = pMCDSurface;
  435. pRc->pMCDRc = pMCDRc;
  436. pRc->xOffset = pMCDSurface->pWnd->clientRect.left -
  437. pRc->viewportXAdjust;
  438. pRc->yOffset = (pMCDSurface->pWnd->clientRect.top -
  439. pMCDSurface->pWnd->clipBoundsRect.top) -
  440. pRc->viewportYAdjust;
  441. pRc->pMemMin = pStart;
  442. pRc->pvProvoking = (MCDVERTEX *)pStart; // bulletproofing
  443. pRc->pMemMax = pEnd - sizeof(MCDVERTEX);
  444. // warm up the hardware for drawing primitives:
  445. HW_INIT_DRAWING_STATE(pMCDSurface, pMCDSurface->pWnd, pRc);
  446. HW_INIT_PRIMITIVE_STATE(pMCDSurface, pRc);
  447. // If we have a single clipping rectangle, set it up in the hardware once
  448. // for this batch:
  449. if (pRc->pEnumClip->c == 1)
  450. (*pRc->HWSetupClipRect)(pRc, &pRc->pEnumClip->arcl[0]);
  451. // Now, loop through the commands and process the batch:
  452. try {
  453. while (pCmd && (UCHAR *)pCmd < pEnd) {
  454. volatile ULONG command = pCmd->command;
  455. // Make sure we can read at least the command header:
  456. if ((pEnd - (UCHAR *)pCmd) < sizeof(MCDCOMMAND))
  457. goto DrawExit;
  458. if (command <= GL_POLYGON) {
  459. if (pCmd->flags & MCDCOMMAND_RENDER_PRIMITIVE)
  460. pCmdNext = (*pRc->primFunc[command])(pRc, pCmd);
  461. else
  462. pCmdNext = pCmd->pNextCmd;
  463. if (pCmdNext == pCmd)
  464. goto DrawExit; // primitive failed
  465. if (!(pCmd = pCmdNext)) { // we're done with the batch
  466. CHOP_ROUND_OFF();
  467. HW_DEFAULT_STATE(pMCDSurface);
  468. #if FORCE_SYNC
  469. HW_WAIT_DRAWING_DONE(pRc);
  470. #endif
  471. return (ULONG)0;
  472. }
  473. }
  474. }
  475. } except (EXCEPTION_EXECUTE_HANDLER) {
  476. MCDBG_PRINT("!!Exception in MCDrvDraw!!");
  477. CHOP_ROUND_OFF();
  478. HW_DEFAULT_STATE(pMCDSurface);
  479. HW_WAIT_DRAWING_DONE(pRc);
  480. return (ULONG_PTR)pCmd;
  481. }
  482. DrawExit:
  483. CHOP_ROUND_OFF();
  484. // restore the hardware state:
  485. HW_DEFAULT_STATE(pMCDSurface);
  486. HW_WAIT_DRAWING_DONE(pRc);
  487. return (ULONG_PTR)pCmd; // some sort of overrun has occurred
  488. }
  489. ULONG MCDrvClear(MCDSURFACE *pMCDSurface, MCDRC *pMCDRc, ULONG buffers)
  490. {
  491. DEVRC *pRc = (DEVRC *)pMCDRc->pvUser;
  492. MCDWINDOW *pWnd;
  493. ULONG cClip;
  494. RECTL *pClip;
  495. // MCDBG_PRINT("MCDrvClear");
  496. MCD_CHECK_RC(pRc);
  497. pWnd = pMCDSurface->pWnd;
  498. MCD_CHECK_BUFFERS_VALID(pMCDSurface, pRc, TRUE);
  499. pRc->ppdev = (PDEV *)pMCDSurface->pso->dhpdev;
  500. #if FAIL_ALL_DRAWING && OKOK
  501. {
  502. HW_WAIT_DRAWING_DONE(pRc);
  503. return FALSE;
  504. }
  505. #endif
  506. if (buffers & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT |
  507. GL_ACCUM_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) {
  508. HW_WAIT_DRAWING_DONE(pRc);
  509. return FALSE;
  510. }
  511. if ((buffers & GL_DEPTH_BUFFER_BIT) && (!pRc->zBufEnabled))
  512. {
  513. MCDBG_PRINT("MCDrvClear: clear z requested with z-buffer disabled.");
  514. HW_WAIT_DRAWING_DONE(pRc);
  515. return FALSE;
  516. }
  517. if (buffers & (GL_ACCUM_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) {
  518. HW_WAIT_DRAWING_DONE(pRc);
  519. return FALSE;
  520. }
  521. // Return if we have nothing to clear:
  522. if (!(cClip = pWnd->pClip->c))
  523. return TRUE;
  524. // Initialize hardware state for filling operation:
  525. HW_INIT_DRAWING_STATE(pMCDSurface, pMCDSurface->pWnd, pRc);
  526. // We have to protect against bad clear colors since this can
  527. // potentially cause an FP exception:
  528. try {
  529. HW_START_FILL_RECT(pMCDSurface, pMCDRc, pRc, buffers);
  530. } except (EXCEPTION_EXECUTE_HANDLER) {
  531. MCDBG_PRINT("!!Exception in MCDrvClear!!");
  532. return FALSE;
  533. }
  534. for (pClip = &pWnd->pClip->arcl[0]; cClip; cClip--,
  535. pClip++)
  536. {
  537. // Do the fill:
  538. HW_FILL_RECT(pMCDSurface, pRc, pClip);
  539. }
  540. HW_DEFAULT_STATE(pMCDSurface);
  541. #if FORCE_SYNC
  542. HW_WAIT_DRAWING_DONE(pRc);
  543. #endif
  544. return (ULONG)TRUE;
  545. }
  546. ULONG MCDrvSwap(MCDSURFACE *pMCDSurface, ULONG flags)
  547. {
  548. MCDWINDOW *pWnd;
  549. ULONG cClip;
  550. RECTL *pClip;
  551. POINTL ptSrc;
  552. ULONG vCount, vCountLast;
  553. ULONG scanTarget;
  554. PDEV *ppdev = (PDEV *)pMCDSurface->pso->dhpdev;
  555. ULONG scanMax;
  556. ULONG maxScanOffset;
  557. DEVWND *pDevWnd = (DEVWND *)(pMCDSurface->pWnd->pvUser);
  558. LONG hwBufferYBias;
  559. // MCDBG_PRINT("MCDrvSwap");
  560. pWnd = pMCDSurface->pWnd;
  561. // If we're not tracking this window, just return...
  562. if (!pWnd) {
  563. MCDBG_PRINT("MCDrvSwap: trying to swap an untracked window");\
  564. return FALSE;
  565. }
  566. if (!pDevWnd) {
  567. MCDBG_PRINT("MCDrvSwap: NULL buffers.");\
  568. return FALSE;
  569. }
  570. if (!pDevWnd->bValidBackBuffer) {
  571. MCDBG_PRINT("MCDrvSwap: back buffer invalid");
  572. return FALSE;
  573. }
  574. if (pDevWnd->dispUnique != GetDisplayUniqueness(ppdev)) {
  575. MCDBG_PRINT("MCDrvSwap: resolution changed but not updated");
  576. return FALSE;
  577. }
  578. // Just return if we have nothing to swap:
  579. //
  580. // - no visible rectangle
  581. // - per-plane swap, but none of the specified planes
  582. // are supported by driver
  583. if (!(cClip = pWnd->pClipUnscissored->c) ||
  584. (flags && !(flags & MCDSWAP_MAIN_PLANE)))
  585. return TRUE;
  586. HW_START_SWAP_BUFFERS(pMCDSurface, &hwBufferYBias, flags);
  587. // Wait for sync if we can do a fast blt:
  588. if ((pDevWnd->createFlags & MCDCONTEXT_SWAPSYNC) &&
  589. ((pWnd->clientRect.bottom + pDevWnd->backBufferY) <= (ULONG)ppdev->ayBreak[0])) {
  590. LONG vCount, vCountLast;
  591. LONG scanTarget = pWnd->clientRect.bottom;
  592. LONG scanMax = ppdev->cyScreen - 1;
  593. scanTarget = min(scanTarget, scanMax);
  594. vCount = vCountLast = HW_GET_VCOUNT(ppdev->pjBase);
  595. while ((vCount < scanTarget) && ((vCount - vCountLast) >= 0)) {
  596. vCountLast = vCount;
  597. vCount = HW_GET_VCOUNT(ppdev->pjBase);
  598. }
  599. }
  600. pClip = &pWnd->pClipUnscissored->arcl[0];
  601. ptSrc.x = pWnd->clipBoundsRect.left;
  602. ptSrc.y = pWnd->clipBoundsRect.top + hwBufferYBias;
  603. // Swap all of the clip rectangles in the backbuffer to the front:
  604. ppdev->xOffset = 0;
  605. ppdev->yOffset = 0;
  606. vMilCopyBlt(ppdev, cClip, pClip, 0xcccc,
  607. &ptSrc, &pWnd->clipBoundsRect);
  608. HW_DEFAULT_STATE(pMCDSurface);
  609. return (ULONG)TRUE;
  610. }
  611. ULONG MCDrvState(MCDSURFACE *pMCDSurface, MCDRC *pMCDRc, MCDMEM *pMCDMem,
  612. UCHAR *pStart, LONG length, ULONG numStates)
  613. {
  614. DEVRC *pRc = (DEVRC *)pMCDRc->pvUser;
  615. MCDSTATE *pState = (MCDSTATE *)pStart;
  616. MCDSTATE *pStateEnd = (MCDSTATE *)(pStart + length);
  617. // MCDBG_PRINT("MCDrvState");
  618. MCD_CHECK_RC(pRc);
  619. while (pState < pStateEnd) {
  620. if (((UCHAR *)pStateEnd - (UCHAR *)pState) < sizeof(MCDSTATE)) {
  621. MCDBG_PRINT("MCDrvState: buffer too small");
  622. return FALSE;
  623. }
  624. switch (pState->state) {
  625. case MCD_RENDER_STATE:
  626. if (((UCHAR *)pState + sizeof(MCDRENDERSTATE)) >
  627. (UCHAR *)pStateEnd)
  628. return FALSE;
  629. memcpy(&pRc->MCDState, &pState->stateValue,
  630. sizeof(MCDRENDERSTATE));
  631. // Flag the fact that we need to re-pick the
  632. // rendering functions:
  633. pRc->pickNeeded = TRUE;
  634. pState = (MCDSTATE *)((UCHAR *)pState + sizeof(MCDSTATE_RENDER));
  635. break;
  636. case MCD_PIXEL_STATE:
  637. // Not accelerated in this driver, so we can ignore this state
  638. // (which implies that we do not need to set the pick flag).
  639. pState = (MCDSTATE *)((UCHAR *)pState + sizeof(MCDSTATE_PIXEL));
  640. break;
  641. case MCD_SCISSOR_RECT_STATE:
  642. // Not needed in this driver, so we can ignore this state
  643. // (which implies that we do not need to set the pick flag).
  644. pState = (MCDSTATE *)((UCHAR *)pState + sizeof(MCDSTATE_SCISSOR_RECT));
  645. break;
  646. default:
  647. MCDBG_PRINT("MCDrvState: Unrecognized state %d.", pState->state);
  648. return FALSE;
  649. }
  650. }
  651. return (ULONG)TRUE;
  652. }
  653. ULONG MCDrvViewport(MCDSURFACE *pMCDSurface, MCDRC *pMCDRc,
  654. MCDVIEWPORT *pMCDViewport)
  655. {
  656. DEVRC *pRc = (DEVRC *)pMCDRc->pvUser;
  657. // MCDBG_PRINT("MCDrvViewport");
  658. MCD_CHECK_RC(pRc);
  659. pRc->MCDViewport = *pMCDViewport;
  660. return (ULONG)TRUE;
  661. }
  662. HDEV MCDrvGetHdev(MCDSURFACE *pMCDSurface)
  663. {
  664. PDEV *ppdev = (PDEV *)pMCDSurface->pso->dhpdev;
  665. // MCDBG_PRINT("MCDrvGetHdev");
  666. return ppdev->hdevEng;
  667. }
  668. ULONG MCDrvSpan(MCDSURFACE *pMCDSurface, MCDRC *pMCDRc, MCDMEM *pMCDMem,
  669. MCDSPAN *pMCDSpan, BOOL bRead)
  670. {
  671. DEVRC *pRc = (DEVRC *)pMCDRc->pvUser;
  672. PDEV *ppdev = (PDEV *)pMCDSurface->pso->dhpdev;
  673. UCHAR *pScreen;
  674. UCHAR *pPixels;
  675. MCDWINDOW *pWnd;
  676. DEVWND *pDevWnd;
  677. LONG xLeftOrg, xLeft, xRight, y;
  678. LONG bufferYBias;
  679. ULONG bytesNeeded;
  680. ULONG cjHwPel;
  681. // MCDBG_PRINT("MCDrvSpan: read %d, (%d, %d) type %d", bRead, pMCDSpan->x, pMCDSpan->y, pMCDSpan->type);
  682. MCD_CHECK_RC(pRc);
  683. pWnd = pMCDSurface->pWnd;
  684. // Return if we have nothing to clip:
  685. if (!pWnd->pClip->c)
  686. return TRUE;
  687. // Fail if number of pixels is negative:
  688. if (pMCDSpan->numPixels < 0) {
  689. MCDBG_PRINT("MCDrvSpan: numPixels < 0");
  690. return FALSE;
  691. }
  692. MCD_CHECK_BUFFERS_VALID(pMCDSurface, pRc, TRUE);
  693. pDevWnd = (DEVWND *)pWnd->pvUser;
  694. xLeft = xLeftOrg = (pMCDSpan->x + pWnd->clientRect.left);
  695. xRight = (xLeft + pMCDSpan->numPixels);
  696. y = pMCDSpan->y + pWnd->clientRect.top;
  697. // Early-out spans which are not visible:
  698. if ((y < pWnd->clipBoundsRect.top) ||
  699. (y >= pWnd->clipBoundsRect.bottom))
  700. return TRUE;
  701. xLeft = max(xLeft, pWnd->clipBoundsRect.left);
  702. xRight = min(xRight, pWnd->clipBoundsRect.right);
  703. // Return if empty:
  704. if (xLeft >= xRight)
  705. return TRUE;
  706. switch (pMCDSpan->type) {
  707. case MCDSPAN_FRONT:
  708. //MCDBG_PRINT("MCDrvSpan: MCDSPAN_FRONT");
  709. cjHwPel = ppdev->cjHwPel;
  710. pScreen = ppdev->pjScreen + (ppdev->ulYDstOrg * cjHwPel);
  711. bytesNeeded = pMCDSpan->numPixels * cjHwPel;
  712. pScreen += ((y * ppdev->lDelta) +
  713. (xLeft * cjHwPel));
  714. break;
  715. case MCDSPAN_BACK:
  716. //MCDBG_PRINT("MCDrvSpan: MCDSPAN_BACK");
  717. cjHwPel = ppdev->cjHwPel;
  718. pScreen = ppdev->pjScreen + (ppdev->ulYDstOrg * cjHwPel);
  719. bytesNeeded = pMCDSpan->numPixels * cjHwPel;
  720. if (ppdev->pohBackBuffer == pDevWnd->pohBackBuffer) {
  721. pScreen += ((y * ppdev->lDelta) +
  722. (xLeft * cjHwPel) +
  723. pDevWnd->backBufferOffset);
  724. } else {
  725. pScreen += (((y - pWnd->clipBoundsRect.top) * ppdev->lDelta) +
  726. (xLeft * cjHwPel) +
  727. pDevWnd->backBufferOffset);
  728. }
  729. break;
  730. case MCDSPAN_DEPTH:
  731. //MCDBG_PRINT("MCDrvSpan: MCDSPAN_DEPTH");
  732. cjHwPel = 2; // Z is always 16bpp
  733. pScreen = ppdev->pjScreen + (ppdev->ulYDstOrg << 1);
  734. bytesNeeded = pMCDSpan->numPixels * 2;
  735. if (ppdev->pohZBuffer == pDevWnd->pohZBuffer) {
  736. pScreen += (((y * ppdev->cxScreen + xLeft) * 2) +
  737. pDevWnd->zBufferOffset);
  738. } else {
  739. pScreen += (((((y - pWnd->clipBoundsRect.top) * ppdev->cxScreen) + xLeft) * 2) +
  740. pDevWnd->zBufferOffset);
  741. }
  742. break;
  743. default:
  744. MCDBG_PRINT("MCDrvReadSpan: Unrecognized buffer %d", pMCDSpan->type);
  745. return FALSE;
  746. }
  747. // Make sure we don't read past the end of the buffer:
  748. if (((char *)pMCDSpan->pPixels + bytesNeeded) >
  749. ((char *)pMCDMem->pMemBase + pMCDMem->memSize)) {
  750. MCDBG_PRINT("MCDrvSpan: Buffer too small");
  751. return FALSE;
  752. }
  753. WAIT_NOT_BUSY(ppdev->pjBase);
  754. pPixels = pMCDSpan->pPixels;
  755. if (bRead) {
  756. if (xLeftOrg != xLeft)
  757. pPixels = (UCHAR *)pMCDSpan->pPixels + ((xLeft - xLeftOrg) * cjHwPel);
  758. RtlCopyMemory(pPixels, pScreen, (xRight - xLeft) * cjHwPel);
  759. } else {
  760. LONG xLeftClip, xRightClip, yClip;
  761. RECTL *pClip;
  762. ULONG cClip;
  763. for (pClip = &pWnd->pClip->arcl[0], cClip = pWnd->pClip->c; cClip;
  764. cClip--, pClip++)
  765. {
  766. UCHAR *pScreenClip;
  767. // Test for trivial cases:
  768. if (y < pClip->top)
  769. break;
  770. // Determine trivial rejection for just this span
  771. if ((xLeft >= pClip->right) ||
  772. (y >= pClip->bottom) ||
  773. (xRight <= pClip->left))
  774. continue;
  775. // Intersect current clip rect with the span:
  776. xLeftClip = max(xLeft, pClip->left);
  777. xRightClip = min(xRight, pClip->right);
  778. if (xLeftClip >= xRightClip)
  779. continue;
  780. if (xLeftOrg != xLeftClip)
  781. pPixels = (UCHAR *)pMCDSpan->pPixels +
  782. ((xLeftClip - xLeftOrg) * cjHwPel);
  783. pScreenClip = pScreen + ((xLeftClip - xLeft) * cjHwPel);
  784. // Write the span:
  785. RtlCopyMemory(pScreenClip, pPixels, (xRightClip - xLeftClip) * cjHwPel);
  786. }
  787. }
  788. return (ULONG)TRUE;
  789. }
  790. VOID MCDrvTrackWindow(WNDOBJ *pWndObj, MCDWINDOW *pMCDWnd, ULONG flags)
  791. {
  792. // MCDBG_PRINT("MCDrvTrackWindow");
  793. SURFOBJ *pso = pWndObj->psoOwner;
  794. //
  795. // Note: pMCDWnd is NULL for surface notifications, so if needed
  796. // they should be handled before this check:
  797. //
  798. if (!pMCDWnd)
  799. return;
  800. if (!pMCDWnd->pvUser) {
  801. MCDBG_PRINT("MCDrvTrackWindow: NULL pDevWnd");
  802. return;
  803. }
  804. switch (flags) {
  805. case WOC_DELETE:
  806. //MCDBG_PRINT("MCDrvTrackWindow: WOC_DELETE");
  807. // If the display resoultion has changed, the resources we had
  808. // bound to the tracked window are gone, so don't try to delete
  809. // the back- and z-buffer resources which are no longer present:
  810. if (((DEVWND *)pMCDWnd->pvUser)->dispUnique ==
  811. GetDisplayUniqueness((PDEV *)pso->dhpdev))
  812. HWFreeResources(pMCDWnd, pso);
  813. MCDFree((VOID *)pMCDWnd->pvUser);
  814. pMCDWnd->pvUser = NULL;
  815. break;
  816. case WOC_RGN_CLIENT:
  817. // The resources we had bound to the tracked window have moved,
  818. // so update them:
  819. {
  820. DEVWND *pWnd = (DEVWND *)pMCDWnd->pvUser;
  821. BOOL bZBuffer = (pWnd->pohZBuffer != NULL);
  822. BOOL bBackBuffer = (pWnd->pohBackBuffer != NULL);
  823. PDEV *ppdev = (PDEV *)pso->dhpdev;
  824. ULONG height = pMCDWnd->clientRect.bottom - pMCDWnd->clientRect.top;
  825. BOOL bWindowBuffer = (bZBuffer && (pWnd->pohZBuffer != ppdev->pohZBuffer)) ||
  826. (bBackBuffer && (pWnd->pohBackBuffer != ppdev->pohBackBuffer));
  827. // If the window is using a window-sized back/z resource,
  828. // we need to reallocate it if there has been a size change:
  829. if (pWnd->dispUnique == GetDisplayUniqueness(ppdev)) {
  830. if ((height != pWnd->allocatedBufferHeight) &&
  831. (bWindowBuffer)) {
  832. HWFreeResources(pMCDWnd, pso);
  833. HWAllocResources(pMCDWnd, pso, bZBuffer, bBackBuffer);
  834. }
  835. } else {
  836. // In this case, the display has been re-initialized due
  837. // to some event such as a resolution change, so we need
  838. // to create our buffes from scratch:
  839. pWnd->dispUnique = GetDisplayUniqueness((PDEV *)pso->dhpdev);
  840. HWAllocResources(pMCDWnd, pso, bZBuffer, bBackBuffer);
  841. }
  842. }
  843. break;
  844. default:
  845. break;
  846. }
  847. return;
  848. }
  849. ULONG MCDrvBindContext(MCDSURFACE *pMCDSurface, MCDRC *pMCDRc)
  850. {
  851. DEVWND *pDevWnd = (DEVWND *)(pMCDSurface->pWnd->pvUser);
  852. PDEV *ppdev = (PDEV *)pMCDSurface->pso->dhpdev;
  853. // OK, this is a new binding, so create the per-window structure and
  854. // set the pixel format:
  855. if (!pDevWnd) {
  856. pDevWnd = pMCDSurface->pWnd->pvUser = (DEVWND *)MCDAlloc(sizeof(DEVWND));
  857. if (!pDevWnd) {
  858. MCDBG_PRINT("MCDrvBindContext: couldn't allocate DEVWND");
  859. return FALSE;
  860. }
  861. pDevWnd->createFlags = pMCDRc->createFlags;
  862. pDevWnd->iPixelFormat = pMCDRc->iPixelFormat;
  863. pDevWnd->dispUnique = GetDisplayUniqueness(ppdev);
  864. return TRUE;
  865. }
  866. if (pMCDRc->iPixelFormat != pDevWnd->iPixelFormat) {
  867. MCDBG_PRINT("MCDrvBindContext: tried to bind unmatched pixel formats");
  868. return FALSE;
  869. }
  870. HWUpdateBufferPos(pMCDSurface->pWnd, pMCDSurface->pso, TRUE);
  871. return TRUE;
  872. }
  873. ULONG MCDrvSync(MCDSURFACE *pMCDSurface, MCDRC *pMCDRc)
  874. {
  875. DEVRC *pRc = (DEVRC *)pMCDRc->pvUser;
  876. pRc->ppdev = (PDEV *)pMCDSurface->pso->dhpdev;
  877. HW_WAIT_DRAWING_DONE(pRc);
  878. return TRUE;
  879. }
  880. ULONG MCDrvCreateTexture(MCDSURFACE *pMCDSurface, MCDRC *pRc, MCDTEXTURE *pTex)
  881. {
  882. //MCDBG_PRINT("MCDrvCreateTexture");
  883. #ifdef TEST_TEXTURE
  884. pTex->textureKey = 0x1000;
  885. return 1;
  886. #else
  887. return 0;
  888. #endif
  889. }
  890. ULONG MCDrvUpdateSubTexture(MCDSURFACE *pMCDSurface, MCDRC *pRc,
  891. MCDTEXTURE *pTex, ULONG lod, RECTL *pRect)
  892. {
  893. //MCDBG_PRINT("MCDrvUpdateSubTexture");
  894. return TRUE;
  895. }
  896. ULONG MCDrvUpdateTexturePalette(MCDSURFACE *pMCDSurface, MCDRC *pRc,
  897. MCDTEXTURE *pTex, ULONG start,
  898. ULONG numEntries)
  899. {
  900. //MCDBG_PRINT("MCDrvUpdateTexturePalette");
  901. return TRUE;
  902. }
  903. ULONG MCDrvUpdateTexturePriority(MCDSURFACE *pMCDSurface, MCDRC *pRc,
  904. MCDTEXTURE *pTex)
  905. {
  906. //MCDBG_PRINT("MCDrvUpdateTexturePriority");
  907. return TRUE;
  908. }
  909. ULONG MCDrvUpdateTextureState(MCDSURFACE *pMCDSurface, MCDRC *pRc,
  910. MCDTEXTURE *pTex)
  911. {
  912. //MCDBG_PRINT("MCDrvUpdateTextureState");
  913. return TRUE;
  914. }
  915. ULONG MCDrvTextureStatus(MCDSURFACE *pMCDSurface, MCDRC *pRc,
  916. MCDTEXTURE *pTex)
  917. {
  918. //MCDBG_PRINT("MCDrvTextureStatus");
  919. return MCDRV_TEXTURE_RESIDENT;
  920. }
  921. ULONG MCDrvDeleteTexture(MCDTEXTURE *pTex, DHPDEV dhpdev)
  922. {
  923. //MCDBG_PRINT("MCDrvDeleteTexture");
  924. return TRUE;
  925. }
  926. ULONG MCDrvDrawPixels(MCDSURFACE *pMcdSurface, MCDRC *pRc,
  927. ULONG width, ULONG height, ULONG format,
  928. ULONG type, VOID *pPixels, BOOL packed)
  929. {
  930. //MCDBG_PRINT("MCDrvDrawPixels");
  931. return FALSE;
  932. }
  933. ULONG MCDrvReadPixels(MCDSURFACE *pMcdSurface, MCDRC *pRc,
  934. LONG x, LONG y, ULONG width, ULONG height,
  935. ULONG format, ULONG type, VOID *pPixels)
  936. {
  937. //MCDBG_PRINT("MCDrvReadPixels");
  938. return FALSE;
  939. }
  940. ULONG MCDrvCopyPixels(MCDSURFACE *pMcdSurface, MCDRC *pRc,
  941. LONG x, LONG y, ULONG width, ULONG height, ULONG type)
  942. {
  943. //MCDBG_PRINT("MCDrvCopyPixels");
  944. return FALSE;
  945. }
  946. ULONG MCDrvPixelMap(MCDSURFACE *pMcdSurface, MCDRC *pRc,
  947. ULONG mapType, ULONG mapSize, VOID *pMap)
  948. {
  949. //MCDBG_PRINT("MCDrvPixelMap");
  950. return TRUE;
  951. }
  952. BOOL MCDrvGetEntryPoints(MCDSURFACE *pMCDSurface, MCDDRIVER *pMCDDriver)
  953. {
  954. if (pMCDDriver->ulSize < sizeof(MCDDRIVER))
  955. return FALSE;
  956. pMCDDriver->pMCDrvInfo = MCDrvInfo;
  957. pMCDDriver->pMCDrvDescribePixelFormat = MCDrvDescribePixelFormat;
  958. pMCDDriver->pMCDrvDescribeLayerPlane = MCDrvDescribeLayerPlane;
  959. pMCDDriver->pMCDrvSetLayerPalette = MCDrvSetLayerPalette;
  960. pMCDDriver->pMCDrvCreateContext = MCDrvCreateContext;
  961. pMCDDriver->pMCDrvDeleteContext = MCDrvDeleteContext;
  962. pMCDDriver->pMCDrvCreateTexture = MCDrvCreateTexture;
  963. pMCDDriver->pMCDrvDeleteTexture = MCDrvDeleteTexture;
  964. pMCDDriver->pMCDrvCreateMem = MCDrvCreateMem;
  965. pMCDDriver->pMCDrvDeleteMem = MCDrvDeleteMem;
  966. pMCDDriver->pMCDrvDraw = MCDrvDraw;
  967. pMCDDriver->pMCDrvClear = MCDrvClear;
  968. pMCDDriver->pMCDrvSwap = MCDrvSwap;
  969. pMCDDriver->pMCDrvState = MCDrvState;
  970. pMCDDriver->pMCDrvViewport = MCDrvViewport;
  971. pMCDDriver->pMCDrvGetHdev = MCDrvGetHdev;
  972. pMCDDriver->pMCDrvSpan = MCDrvSpan;
  973. pMCDDriver->pMCDrvTrackWindow = MCDrvTrackWindow;
  974. pMCDDriver->pMCDrvAllocBuffers = MCDrvAllocBuffers;
  975. pMCDDriver->pMCDrvGetBuffers = MCDrvGetBuffers;
  976. pMCDDriver->pMCDrvBindContext = MCDrvBindContext;
  977. pMCDDriver->pMCDrvSync = MCDrvSync;
  978. pMCDDriver->pMCDrvCreateTexture = MCDrvCreateTexture;
  979. pMCDDriver->pMCDrvDeleteTexture = MCDrvDeleteTexture;
  980. pMCDDriver->pMCDrvUpdateSubTexture = MCDrvUpdateSubTexture;
  981. pMCDDriver->pMCDrvUpdateTexturePalette = MCDrvUpdateTexturePalette;
  982. pMCDDriver->pMCDrvUpdateTexturePriority = MCDrvUpdateTexturePriority;
  983. pMCDDriver->pMCDrvUpdateTextureState = MCDrvUpdateTextureState;
  984. pMCDDriver->pMCDrvTextureStatus = MCDrvTextureStatus;
  985. pMCDDriver->pMCDrvDrawPixels = MCDrvDrawPixels;
  986. pMCDDriver->pMCDrvReadPixels = MCDrvReadPixels;
  987. pMCDDriver->pMCDrvCopyPixels = MCDrvCopyPixels;
  988. pMCDDriver->pMCDrvPixelMap = MCDrvPixelMap;
  989. return TRUE;
  990. }
  991. /******************************Public*Routine******************************\
  992. * VOID vAssertModeMCD
  993. *
  994. * This function is called by enable.c when entering or leaving the
  995. * DOS full-screen character mode.
  996. *
  997. \**************************************************************************/
  998. VOID vAssertModeMCD(
  999. PDEV* ppdev,
  1000. BOOL bEnabled)
  1001. {
  1002. }
  1003. /******************************Public*Routine******************************\
  1004. * BOOL bEnableMCD
  1005. *
  1006. * This function is called by enable.c when the mode is first initialized,
  1007. * right after the miniport does the mode-set.
  1008. *
  1009. \**************************************************************************/
  1010. BOOL bEnableMCD(
  1011. PDEV* ppdev)
  1012. {
  1013. return(TRUE);
  1014. }
  1015. /******************************Public*Routine******************************\
  1016. * VOID vDisableMCD
  1017. *
  1018. * This function is called by enable.c when the driver is shutting down.
  1019. *
  1020. \**************************************************************************/
  1021. VOID vDisableMCD(
  1022. PDEV* ppdev)
  1023. {
  1024. if (ppdev->hMCD)
  1025. {
  1026. EngUnloadImage(ppdev->hMCD);
  1027. }
  1028. }