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.

247 lines
7.8 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: mcdpoint.c
  3. *
  4. * Contains all of the point-rendering routines for the Cirrus Logic 546X MCD driver.
  5. *
  6. * (based on mcdpoint.c from NT4.0 DDK)
  7. *
  8. * Copyright (c) 1996 Microsoft Corporation
  9. * Copyright (c) 1997 Cirrus Logic, Inc.
  10. \**************************************************************************/
  11. #include "precomp.h"
  12. #include "mcdhw.h"
  13. #include "mcdutil.h"
  14. #include "mcdmath.h"
  15. #define TRUNCCOORD(value, intValue)\
  16. intValue = __MCD_VERTEX_FIXED_TO_INT(__MCD_VERTEX_FLOAT_TO_FIXED(value))
  17. VOID FASTCALL __MCDRenderPoint(DEVRC *pRc, MCDVERTEX *a)
  18. {
  19. ULONG clipNum;
  20. RECTL *pClip;
  21. LONG lCoord;
  22. PDEV *ppdev = pRc->ppdev;
  23. unsigned int *pdwNext = ppdev->LL_State.pDL->pdwNext;
  24. // output queue stuff...
  25. DWORD *pSrc;
  26. DWORD *pDest = ppdev->LL_State.pRegs + HOST_3D_DATA_PORT;
  27. DWORD *pdwStart = ppdev->LL_State.pDL->pdwStartOutPtr;
  28. DWORD dwFlags=0; // MCD_TEMP - dwflags initialized to 0
  29. DWORD *dwOrig; /* Temp display list pointer */
  30. DWORD dwOpcode; // Built opcode
  31. LONG ax, ay;
  32. if ((clipNum = pRc->pEnumClip->c) > 1) {
  33. pClip = &pRc->pEnumClip->arcl[0];
  34. SET_HW_CLIP_REGS(pRc,pdwNext)
  35. pClip++;
  36. }
  37. // window coords are float values, and need to have
  38. // viewportadjust (MCDVIEWPORT) values subtracted to get to real screen space
  39. // color values are 0->1 floats and must be multiplied by scale values (MCDRCINFO)
  40. // to get to nbits range (scale = 0xff for 8 bit, 0x7 for 3 bit, etc.)
  41. // Z values are 0->1 floats(?) and must be multiplied by zscale(?) values (MCDRCINFO)
  42. #if 0 // FUTURE - need to enable 3d control regs setup for texture
  43. // Turn on alpha blending if it is required and is not already on
  44. // Also turn it off if it is on and is not required
  45. //
  46. // Note: LL_ALPHA bit should be 1
  47. //
  48. if( (dwFlags ^ (LL_State.dwControl0>>15)) & 1 )
  49. {
  50. // Alpha enable is bit 15 in control0, so toggle it
  51. //
  52. LL_State.dwControl0 ^= 0x00008000; // bit 15
  53. *pdwNext++ = write_register( CONTROL0_3D, 1 );
  54. *pdwNext++ = LL_State.dwControl0;
  55. }
  56. #if 0 // MCD never uses alpha_mode 0
  57. // Set up the da_main, da_ortho registers necessary for
  58. // constant alpha blending
  59. // ========
  60. if( (dwFlags & LL_ALPHA) && (LL_State.Control0.Alpha_Mode == 0) )
  61. {
  62. // Check if a new value needs to be set
  63. //
  64. if( LL_State.rDA_MAIN != LL_State.AlphaConstSource ||
  65. LL_State.rDA_ORTHO != LL_State.AlphaConstDest )
  66. {
  67. *(pdwNext+0) = write_register( DA_MAIN_3D, 2 );
  68. *(pdwNext+1) = LL_State.rDA_MAIN = LL_State.AlphaConstSource;
  69. *(pdwNext+2) = LL_State.rDA_ORTHO = LL_State.AlphaConstDest;
  70. pdwNext += 3;
  71. }
  72. }
  73. #endif
  74. // NOTE!!! - caller (MCDPrimDrawPoints) will put this in outlist, which will be sent at end of this proc
  75. // *pdwNext++ = write_register( Y_COUNT_3D, 1 );
  76. // *pdwNext++ = 0;
  77. #endif 0 // FUTURE - (end 3d control regs setup for texture)
  78. // Store the first address for the opcode
  79. //
  80. dwOrig = pdwNext;
  81. // Start with a plain point instruction (no modifiers)
  82. // and assume same color. Count=2 for x,y
  83. //
  84. dwOpcode = POINT | SAME_COLOR | 2;
  85. // Set flags as requested from the dwFlags field of a batch.
  86. // These bits have 1-1 correspondence to their instruction
  87. // counterparts.
  88. //
  89. // Flags : LL_DITHER - Use dither pattern
  90. // LL_PATTERN - Draw pattern
  91. // LL_STIPPLE - Use stipple mask
  92. // LL_LIGHTING - Do lighting
  93. // LL_Z_BUFFER - Use Z buffer
  94. // FETCH_COLOR - Appended for alpha blending
  95. // LL_GOURAUD - Use Gouraud shading
  96. // LL_TEXTURE - Texture mapping
  97. //
  98. /*
  99. dwOpcode |= dwFlags &
  100. ( LL_DITHER | LL_PATTERN | LL_STIPPLE
  101. | LL_LIGHTING | LL_Z_BUFFER | FETCH_COLOR
  102. | LL_GOURAUD | LL_TEXTURE );
  103. */
  104. // no point stippling for OpenGL
  105. dwOpcode |= pRc->privateEnables & __MCDENABLE_Z ;
  106. dwOpcode |= pRc->privateEnables & __MCDENABLE_DITHER ;
  107. //SNAPCOORD(a->windowCoord.x, ax);
  108. TRUNCCOORD(a->windowCoord.x, ax);
  109. lCoord = ax + pRc->xOffset; // adds window offset, removes a000 offset
  110. *(pdwNext+1) = (DWORD) (lCoord << 16 );
  111. //SNAPCOORD(a->windowCoord.y, ay);
  112. TRUNCCOORD(a->windowCoord.y, ay);
  113. lCoord = ay + pRc->yOffset; // adds window offset, removes a000 offset
  114. *(pdwNext+2) = (DWORD) ((lCoord << 16) + 1);
  115. pdwNext += 3;
  116. if( !(dwFlags & LL_SAME_COLOR) )
  117. {
  118. register DWORD color;
  119. // Clear same_color flag
  120. //
  121. dwOpcode ^= LL_SAME_COLOR;
  122. *pdwNext = FTOL(a->colors[0].r * pRc->rScale);
  123. *(pdwNext+1) = FTOL(a->colors[0].g * pRc->gScale);
  124. *(pdwNext+2) = FTOL(a->colors[0].b * pRc->bScale);
  125. dwOpcode += 3;
  126. pdwNext += 3;
  127. }
  128. if( pRc->privateEnables & __MCDENABLE_Z)
  129. {
  130. *pdwNext++ = FTOL(a->windowCoord.z * pRc->zScale);
  131. dwOpcode += 1;
  132. }
  133. #if 0
  134. if( dwFlags & LL_TEXTURE )
  135. {
  136. ...
  137. ...
  138. ...
  139. }
  140. #endif
  141. if (pRc->privateEnables & (__MCDENABLE_BLEND|__MCDENABLE_FOG))
  142. {
  143. float v1alp;
  144. if (pRc->privateEnables & __MCDENABLE_BLEND)
  145. {
  146. // recall that if both blending and fog active, all prims punted back to software
  147. v1alp = a->colors[0].a * pRc->aScale;
  148. }
  149. else
  150. {
  151. v1alp = a->fog * (float)16777215.0; // convert from 0->1.0 val to 0->ff.ffff val
  152. }
  153. *pdwNext++ = FTOL(v1alp) & 0x00ffff00;// bits 31->24 and 7->0 reserved
  154. dwOpcode += ( FETCH_COLOR | ALPHA + 1 );
  155. }
  156. // Store the final opcode
  157. //
  158. *dwOrig = dwOpcode;
  159. while (--clipNum) {
  160. int len = (dwOpcode & 0x3F) + 1; // num words for line primitive
  161. SET_HW_CLIP_REGS(pRc,pdwNext)
  162. pClip++;
  163. // dump same pt regs again to draw while clipping against occlusion rectangle
  164. pSrc = dwOrig;
  165. while( len-- ) *pdwNext++ = *pSrc++;
  166. }
  167. // output queued data here....
  168. #if 0 // FUTURE - enable queueing algorithm - just outputting everything for now
  169. OUTPUT_COPROCMODE_QUEUE
  170. #else // 0
  171. {
  172. pSrc = pdwStart;
  173. while (pSrc != pdwNext)
  174. {
  175. /* Get the amount of data for this opcode */
  176. int len = (*pSrc & 0x3F) + 1;
  177. USB_TIMEOUT_FIX(ppdev)
  178. while( len-- ) *pDest = *pSrc++;
  179. }
  180. }
  181. #endif // 0
  182. ppdev->LL_State.pDL->pdwNext = ppdev->LL_State.pDL->pdwStartOutPtr = pdwStart;
  183. }
  184. VOID FASTCALL __MCDRenderGenPoint(DEVRC *pRc, MCDVERTEX *pv)
  185. {
  186. // MGA and S3 MCD's have no code in this proc
  187. MCDBG_PRINT("__MCDRenderGenPoint - EMPTY ROUTINE");
  188. }