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.

374 lines
13 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: mcdhw.h
  3. *
  4. * Driver-specific structures and defines for the Cirrus Logic 546X MCD driver.
  5. *
  6. * (based on mcdhw.h from NT4.0 DDK)
  7. *
  8. * Copyright (c) 1996 Microsoft Corporation
  9. * Copyright (c) 1997 Cirrus Logic, Inc.
  10. *
  11. \**************************************************************************/
  12. #ifndef _MCDHW_H
  13. #define _MCDHW_H
  14. #if DBG
  15. #define FASTCALL
  16. #else
  17. #ifdef _X86_
  18. #define FASTCALL __fastcall
  19. #else
  20. #define FASTCALL
  21. #endif
  22. #endif
  23. #define ASM_ACCEL 1 // Enable/disable asm code
  24. #define __MCD_USER_CLIP_MASK ((1 << MCD_MAX_USER_CLIP_PLANES) - 1)
  25. // track original vertices unaffected by clip to enable recomputation
  26. // of windowCoords, since this can introduce imprecision
  27. // will use clipCode member of MCDVERTEX for this flag, so position
  28. // should be one not used by a real clip code
  29. #define __MCD_CLIPPED_VTX (1 << (MCD_MAX_USER_CLIP_PLANES+6))
  30. #define __MCD_CW 0
  31. #define __MCD_CCW 1
  32. #define __MCD_FRONTFACE MCDVERTEX_FRONTFACE
  33. #define __MCD_BACKFACE MCDVERTEX_BACKFACE
  34. #define __MCD_NOFACE -1
  35. #define __MCDENABLE_TWOSIDED 0x0001
  36. // use same bits as Opcode word for Cirrus 546x 3D engine
  37. #define __MCDENABLE_Z 0x00002000 // same as LL_Z_BUFFER in LL3D
  38. #define __MCDENABLE_SMOOTH 0x00001000 // same as LL_GOURAUD in LL3D
  39. #define __MCDENABLE_DITHER 0x00200000 // same as LL_DITHER in LL3D
  40. #define __MCDENABLE_PG_STIPPLE 0x00080000 // same as LL_STIPPLE in LL3D
  41. #define __MCDENABLE_TEXTURE 0x00020000 // same as LL_TEXTURE in LL3D
  42. #define __MCDENABLE_PERSPECTIVE 0x00010000 // same as LL_PERSPECTIVE in LL3D
  43. #define __MCDENABLE_LIGHTING 0x00040000 // same as LL_LIGHTING in LL3D
  44. #define __MCDENABLE_BLEND 0x00000002 // no map to LL_ equivalent
  45. #define __MCDENABLE_FOG 0x00000004 // no map to LL_ equivalent
  46. #define __MCDENABLE_1D_TEXTURE 0x00000008 // no map to LL_ equivalent
  47. #define __MCDENABLE_LINE_STIPPLE 0x00000010 // no map to LL_STIPPLE since pg/line stipple independent
  48. #define __MCDENABLE_TEXTUREMASKING 0x00000020 // no map to LL_ equivalent
  49. #define PATTERN_RAM_INVALID 0
  50. #define AREA_PATTERN_LOADED 1
  51. #define STIPPLE_LOADED 2
  52. #define DITHER_LOADED 3
  53. #define LINE_PATTERN_LOADED 4
  54. #define CLMCD_TEX_BOGUS 0x10000000 // Texture is bogus - always punt
  55. // default texture key - remains this if load fails, otherwise is address of texture
  56. // control block, so make sure < 0x80000000 so won't be valid kernel space address
  57. #define TEXTURE_NOT_LOADED 0
  58. #define MCD_CONFORM_ADJUST 1
  59. typedef LONG MCDFIXED;
  60. typedef struct _RGBACOLOR {
  61. MCDFIXED r, g, b, a;
  62. } RGBACOLOR;
  63. #define SWAP_COLOR(p)\
  64. {\
  65. MCDFLOAT tempR, tempG, tempB;\
  66. \
  67. tempR = (p)->colors[0].r;\
  68. (p)->colors[0].r = (p)->colors[1].r;\
  69. (p)->colors[1].r = tempR;\
  70. \
  71. tempG = (p)->colors[0].g;\
  72. (p)->colors[0].g = (p)->colors[1].g;\
  73. (p)->colors[1].g = tempG;\
  74. \
  75. tempB = (p)->colors[0].b;\
  76. (p)->colors[0].b = (p)->colors[1].b;\
  77. (p)->colors[1].b = tempB;\
  78. }
  79. #define SAVE_COLOR(temp, p)\
  80. {\
  81. temp.r = (p)->colors[0].r;\
  82. temp.g = (p)->colors[0].g;\
  83. temp.b = (p)->colors[0].b;\
  84. }
  85. #define RESTORE_COLOR(temp, p)\
  86. {\
  87. (p)->colors[0].r = temp.r;\
  88. (p)->colors[0].g = temp.g;\
  89. (p)->colors[0].b = temp.b;\
  90. }
  91. #define COPY_COLOR(pDst, pSrc)\
  92. {\
  93. pDst.r = pSrc.r;\
  94. pDst.g = pSrc.g;\
  95. pDst.b = pSrc.b;\
  96. }
  97. #define MCDCLAMPCOUNT(value) ((ULONG)(value) & 0x00007fff)
  98. #define MCDFIXEDRGB(fixColor, fltColor)\
  99. fixColor.r = (MCDFIXED)(fltColor.r * pRc->rScale);\
  100. fixColor.g = (MCDFIXED)(fltColor.g * pRc->gScale);\
  101. fixColor.b = (MCDFIXED)(fltColor.b * pRc->bScale);
  102. typedef struct _DRVPIXELFORMAT {
  103. UCHAR cColorBits;
  104. UCHAR rBits;
  105. UCHAR gBits;
  106. UCHAR bBits;
  107. UCHAR aBits;
  108. UCHAR rShift;
  109. UCHAR gShift;
  110. UCHAR bShift;
  111. UCHAR aShift;
  112. } DRVPIXELFORMAT;
  113. typedef struct _DEVWND {
  114. ULONG createFlags; // (RC) creation flags
  115. LONG iPixelFormat; // pixel format ID for this window
  116. ULONG dispUnique; // display resolution uniqueness
  117. ULONG frontBufferPitch; // pitch in bytes
  118. ULONG allocatedBufferHeight; // Same for back and z on Millenium
  119. ULONG allocatedBufferWidth; // 546x supports window width < screen width
  120. BOOL bDesireBackBuffer; // back buffer wanted
  121. BOOL bValidBackBuffer; // back buffer validity
  122. ULONG backBufferBase; // byte offset to start of back buffer pool
  123. ULONG backBufferBaseY; // y value for start of back buffer pool
  124. ULONG backBufferOffset; // byte offset to start of back buffer
  125. ULONG backBufferY; // y value for start of active back buffer
  126. ULONG backBufferPitch; // back buffer pitch in bytes
  127. BOOL bDesireZBuffer; // z buffer wanted
  128. BOOL bValidZBuffer; // z buffer validity
  129. ULONG zBufferBase; // byte offset to start of z buffer pool
  130. ULONG zBufferBaseY; // y value for start of z buffer pool
  131. ULONG zBufferOffset; // byte offset to start of z buffer
  132. ULONG zPitch; // z buffer pitch in bytes
  133. POFMHDL pohBackBuffer; // ofscreen pools
  134. POFMHDL pohZBuffer;
  135. union {
  136. TBase0Reg Base0; // Base0_addr_3d register shadow
  137. DWORD dwBase0;
  138. };
  139. union {
  140. TBase1Reg Base1; // Base1_addr_3d register shadow
  141. DWORD dwBase1;
  142. };
  143. } DEVWND;
  144. typedef struct _DEVRC DEVRC;
  145. // recip table to support up to 2K x 2K resolution
  146. //#define LAST_FRECIP 2048
  147. typedef struct _DEVRC
  148. {
  149. MCDRENDERSTATE MCDState;
  150. MCDTEXENVSTATE MCDTexEnvState;
  151. MCDVIEWPORT MCDViewport;
  152. MCDSURFACE *pMCDSurface; // Valid for primitives only
  153. MCDRC *pMCDRc; // Valid for primitives only
  154. PDEV* ppdev; // Valid for primitives only
  155. ENUMRECTS *pEnumClip; // Valid for primitives only
  156. MCDVERTEX *pvProvoking; // provoking vertex
  157. UCHAR *pMemMax; // command-buffer memory bounds
  158. UCHAR *pMemMin;
  159. LONG iPixelFormat; // valid pixel format ID for this RC
  160. // storage and pointers for clip processing:
  161. MCDVERTEX clipTemp[6 + MCD_MAX_USER_CLIP_PLANES];
  162. MCDVERTEX *pNextClipTemp;
  163. VOID (FASTCALL *lineClipParam)(MCDVERTEX*, const MCDVERTEX*, const MCDVERTEX*, MCDFLOAT);
  164. VOID (FASTCALL *polyClipParam)(MCDVERTEX*, const MCDVERTEX*, const MCDVERTEX*, MCDFLOAT);
  165. // Rendering functions:
  166. VOID (FASTCALL *renderPoint)(DEVRC *pRc, MCDVERTEX *pv);
  167. VOID (FASTCALL *renderLine)(DEVRC *pRc, MCDVERTEX *pv1, MCDVERTEX *pv2, BOOL resetLine);
  168. VOID (FASTCALL *renderTri)(DEVRC *pRc, MCDVERTEX *pv1, MCDVERTEX *pv2, MCDVERTEX *pv3);
  169. VOID (FASTCALL *clipLine)(DEVRC *pRc, MCDVERTEX *pv1, MCDVERTEX *pv2, BOOL bResetLine);
  170. VOID (FASTCALL *clipTri)(DEVRC *pRc, MCDVERTEX *pv1, MCDVERTEX *pv2, MCDVERTEX *pv3, ULONG clipFlags);
  171. VOID (FASTCALL *clipPoly)(DEVRC *pRc, MCDVERTEX *pv, ULONG numVert);
  172. VOID (FASTCALL *doClippedPoly)(DEVRC *pRc, MCDVERTEX **pv, ULONG numVert, ULONG clipFlags);
  173. VOID (FASTCALL *renderPointX)(DEVRC *pRc, MCDVERTEX *pv);
  174. VOID (FASTCALL *renderLineX)(DEVRC *pRc, MCDVERTEX *pv1, MCDVERTEX *pv2, BOOL resetLine);
  175. VOID (FASTCALL *renderTriX)(DEVRC *pRc, MCDVERTEX *pv1, MCDVERTEX *pv2, MCDVERTEX *pv3);
  176. // Primitive-rendering function table:
  177. MCDCOMMAND * (FASTCALL *primFunc[10])(DEVRC *pRc, MCDCOMMAND *pCommand);
  178. // Internal table of rendering functions:
  179. VOID (FASTCALL *drawPoint)(DEVRC *pRc, MCDVERTEX *pv);
  180. VOID (FASTCALL *drawLine)(DEVRC *pRc, MCDVERTEX *pv1, MCDVERTEX *pv2, BOOL resetLine);
  181. VOID (FASTCALL *drawTri)(DEVRC *pRc, MCDVERTEX *pv1, MCDVERTEX *pv2, MCDVERTEX *pv3, int linear_ok);
  182. // Rendering helper functions:
  183. VOID (FASTCALL *HWSetupClipRect)(DEVRC *pRc, RECTL *pRect);
  184. BOOL allPrimFail; // TRUE is the driver can't draw *any*
  185. // primitives for current state
  186. BOOL pickNeeded;
  187. BOOL resetLineStipple;
  188. ULONG polygonFace[2]; // front/back face tables
  189. ULONG polygonMode[2];
  190. MCDFLOAT halfArea;
  191. MCDFLOAT dxAC;
  192. MCDFLOAT dxAB;
  193. MCDFLOAT dxBC;
  194. MCDFLOAT dyAC;
  195. MCDFLOAT dyAB;
  196. MCDFLOAT dyBC;
  197. LONG cullFlag;
  198. MCDFLOAT dzdx, dzdy;
  199. MCDFIXED fxdzdx, fxdzdy;
  200. ULONG xOffset, yOffset;
  201. MCDFLOAT fxOffset, fyOffset;
  202. LONG viewportXAdjust;
  203. LONG viewportYAdjust;
  204. BOOL zBufEnabled;
  205. BOOL backBufEnabled;
  206. ULONG privateEnables;
  207. MCDFLOAT rScale;
  208. MCDFLOAT gScale;
  209. MCDFLOAT bScale;
  210. MCDFLOAT aScale;
  211. MCDFLOAT zScale;
  212. float texture_height;
  213. float texture_bias; // 0 if NEAREST, -0.5 if LINEAR - not a kludge, see OpenGL 1.1 Spec, p 96
  214. float texture_width;
  215. DWORD dwPolyOpcode;
  216. DWORD dwLineOpcode;
  217. DWORD dwPointOpcode;
  218. DEVWND *pLastDevWnd;
  219. union {
  220. TControl0Reg Control0; // Control 0 register shadow
  221. DWORD dwControl0;
  222. };
  223. union {
  224. TTxCtl0Reg TxControl0; // Tx_Ctl0_3D register shadow
  225. DWORD dwTxControl0;
  226. };
  227. union {
  228. TTxXYBaseReg TxXYBase; // Tx_XYBase_3D register shadow
  229. DWORD dwTxXYBase;
  230. };
  231. DWORD dwColor0; // Current value of COLOR_REG0_3D reg
  232. LL_Pattern line_style;
  233. LL_Pattern fill_pattern;
  234. LL_Texture *pLastTexture; // Used to cache textures
  235. float fNumDraws; // how many MCDrvDraws executed since CreateContext
  236. DWORD punt_front_w_windowed_z;
  237. BYTE bAlphaTestRef; // alpha test reference, scaled to 8 bits
  238. RECTL AdjClip;
  239. } DEVRC;
  240. // External declarations
  241. MCDCOMMAND * FASTCALL __MCDPrimDrawPoints(DEVRC *pRc, MCDCOMMAND *pCmd);
  242. MCDCOMMAND * FASTCALL __MCDPrimDrawLines(DEVRC *pRc, MCDCOMMAND *pCmd);
  243. MCDCOMMAND * FASTCALL __MCDPrimDrawLineLoop(DEVRC *pRc, MCDCOMMAND *pCmd);
  244. MCDCOMMAND * FASTCALL __MCDPrimDrawLineStrip(DEVRC *pRc, MCDCOMMAND *pCmd);
  245. MCDCOMMAND * FASTCALL __MCDPrimDrawTriangles(DEVRC *pRc, MCDCOMMAND *pCmd);
  246. MCDCOMMAND * FASTCALL __MCDPrimDrawTriangleStrip(DEVRC *pRc, MCDCOMMAND *pCmd);
  247. MCDCOMMAND * FASTCALL __MCDPrimDrawTriangleFan(DEVRC *pRc, MCDCOMMAND *pCmd);
  248. MCDCOMMAND * FASTCALL __MCDPrimDrawQuads(DEVRC *pRc, MCDCOMMAND *pCmd);
  249. MCDCOMMAND * FASTCALL __MCDPrimDrawQuadStrip(DEVRC *pRc, MCDCOMMAND *pCmd);
  250. MCDCOMMAND * FASTCALL __MCDPrimDrawPolygon(DEVRC *pRc, MCDCOMMAND *_pCmd);
  251. MCDCOMMAND * FASTCALL __MCDPrimDrawStub(DEVRC *pRc, MCDCOMMAND *_pCmd);
  252. // High-level rendering functions:
  253. VOID __MCDPickRenderingFuncs(DEVRC *pRc, DEVWND *pDevWnd);
  254. VOID FASTCALL __MCDRenderPoint(DEVRC *pRc, MCDVERTEX *pv);
  255. VOID FASTCALL __MCDRenderFogPoint(DEVRC *pRc, MCDVERTEX *pv);
  256. VOID FASTCALL __MCDRenderGenPoint(DEVRC *pRc, MCDVERTEX *pv);
  257. VOID FASTCALL __MCDRenderLine(DEVRC *pRc, MCDVERTEX *pv1, MCDVERTEX *pv2, BOOL resetLine);
  258. VOID FASTCALL __MCDRenderGenLine(DEVRC *pRc, MCDVERTEX *pv1, MCDVERTEX *pv2, BOOL resetLine);
  259. VOID FASTCALL __MCDRenderFlatTriangle(DEVRC *pRc, MCDVERTEX *pv1, MCDVERTEX *pv2, MCDVERTEX *pv3);
  260. VOID FASTCALL __MCDRenderSmoothTriangle(DEVRC *pRc, MCDVERTEX *pv1, MCDVERTEX *pv2, MCDVERTEX *pv3);
  261. VOID FASTCALL __MCDRenderGenTriangle(DEVRC *pRc, MCDVERTEX *pv1, MCDVERTEX *pv2, MCDVERTEX *pv3);
  262. // Low-level drawing functions:
  263. VOID FASTCALL __MCDPointBegin(DEVRC *pRc);
  264. VOID FASTCALL __MCDFillTriangle(DEVRC *pRc, MCDVERTEX *pv1, MCDVERTEX *pv2, MCDVERTEX *pv3, int linear_ok);
  265. VOID FASTCALL __MCDPerspTxtTriangle(DEVRC *pRc, MCDVERTEX *pv1, MCDVERTEX *pv2, MCDVERTEX *pv3, int linear_ok);
  266. // Clipping functions:
  267. VOID FASTCALL __MCDPickClipFuncs(DEVRC *pRc);
  268. VOID FASTCALL __MCDClipLine(DEVRC *pRc, MCDVERTEX *a, MCDVERTEX *b,
  269. BOOL bResetLine);
  270. VOID FASTCALL __MCDClipTriangle(DEVRC *pRc, MCDVERTEX *a, MCDVERTEX *b,
  271. MCDVERTEX *c, ULONG orClipCode);
  272. VOID FASTCALL __MCDClipPolygon(DEVRC *pRc, MCDVERTEX *v0, LONG nv);
  273. VOID FASTCALL __MCDDoClippedPolygon(DEVRC *pRc, MCDVERTEX **iv, LONG nout,
  274. ULONG allClipCodes);
  275. VOID FASTCALL __HWAdjustLeftEdgeRGBZ(DEVRC *pRc, MCDVERTEX *p,
  276. MCDFLOAT fdxLeft, MCDFLOAT fdyLeft,
  277. MCDFLOAT xFrac, MCDFLOAT yFrac,
  278. MCDFLOAT xErr);
  279. VOID FASTCALL __HWAdjustRightEdge(DEVRC *pRc, MCDVERTEX *p,
  280. MCDFLOAT fdxRight, MCDFLOAT fdyRight,
  281. MCDFLOAT xErr);
  282. VOID FASTCALL __MCDCalcDeltaRGBZ(DEVRC *pRc, MCDVERTEX *a, MCDVERTEX *b,
  283. MCDVERTEX *c);
  284. MCDFLOAT FASTCALL __MCDGetZOffsetDelta(DEVRC *pRc);
  285. // Fog function
  286. VOID __MCDCalcFogColor(DEVRC *pRc, MCDVERTEX *a, MCDCOLOR *pResult, MCDCOLOR *pColor);
  287. // NOTE: dummy function - should be removed when development complete
  288. VOID FASTCALL __MCDDummyProc(DEVRC *pRc);
  289. #endif //ndef _MCDHW_H