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.

241 lines
9.6 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: dltamacr.h
  15. *
  16. * Content: Hardware specific macro definitions
  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 __DLTAMACR_H
  22. #define __DLTAMACR_H
  23. #define AS_ULONG(val) *((volatile DWORD *) &(val))
  24. // Macros defining the different Vertex types.
  25. #define VTX_FOG (0x1 << 25)
  26. #define VTX_RGB (0x7 << 21)
  27. #define VTX_R (0x1 << 21)
  28. #define VTX_RGBA (0xF << 21)
  29. #define VTX_COLOR (0x1 << 30)
  30. #define VTX_SPECULAR (0x1 << 31)
  31. #define VTX_STQ (0x7 << 16)
  32. #define VTX_KSKD (0x3 << 19)
  33. #define VTX_KS (0x1 << 19)
  34. #define VTX_XYZ (0x7 << 26)
  35. #define VTX_XY (0x3 << 26)
  36. #define VTX_GRP (0x2 << 14)
  37. #define GAMBIT_XYZ_VTX (VTX_GRP | VTX_XYZ)
  38. #define GAMBIT_XYZ_COLOR_VTX (VTX_GRP | VTX_XYZ | VTX_COLOR)
  39. #define GAMBIT_STQ_VTX (VTX_GRP | VTX_STQ)
  40. #define GAMBIT_XYZ_STQ_VTX (VTX_GRP | VTX_XYZ | VTX_STQ)
  41. #ifdef ANTIALIAS
  42. // Scale the screen coordinates by 2 for antialising renderers and bilinear filter down afterwards
  43. #define Y_ADJUST(y) (((y)) * (float)(2.0f))
  44. #else
  45. #define Y_ADJUST(y) ((y))
  46. #endif
  47. //
  48. // This loses one bit of accuracy, but adds and clamps without ifs.
  49. // We first mask all channels with 0xfe. This leaves the lsb of
  50. // each channel clear, so when the terms are added, any carry goes
  51. // into the new highest bit. Now all we have to do is generate a
  52. // mask for any channels that have overflowed. So we shift is right
  53. // and eliminate everything but the overflow bits, so each channel
  54. // contains either 0x00 or 0x01. Subtracting each channel from 0x80
  55. // produces 0x7f or 0x80. We just shift this left once and mask to
  56. // give 0xfe or 0x00. (We could eliminate the final mask here, but
  57. // it would introduce noise into the low-bit of every channel..)
  58. //
  59. #define CLAMP8888(result, color, specular) \
  60. result = (color & 0xfefefefe) + (specular & 0xfefefe); \
  61. result |= ((0x808080 - ((result >> 8) & 0x010101)) & 0x7f7f7f) << 1;
  62. //
  63. // The full mip-level calculation is (log2( texArea/pixArea )) / 2.
  64. // We approximate this by subtracting the exponent of pixArea from
  65. // the exponent of texArea, having converted the floats into their
  66. // bit-wise form. As the exponents start at bit 23, we need to shift
  67. // this difference right by 23 and then once more for the divide by 2.
  68. // We include a bias constant before the final shift to allow matching
  69. // with the true sum-of-squares-of-derivatives calculation ( BIAS_SHIFT
  70. // == 1 ) or whatever other reference image you have.
  71. //
  72. #define MIPSHIFT (23 + 1)
  73. // A bias shift of zero matches 3DWB98's reference mipmap images
  74. #ifndef BIAS_SHIFT
  75. #define BIAS_SHIFT 0
  76. #endif
  77. #define BIAS_CONSTANT (1 << (MIPSHIFT - BIAS_SHIFT))
  78. #define FIND_PERMEDIA_MIPLEVEL() \
  79. { \
  80. int aTex = (int)*(DWORD *)&TextureArea; \
  81. int aPix = (int)*(DWORD *)&PixelArea; \
  82. iNewMipLevel = ((aTex - aPix + BIAS_CONSTANT) >> MIPSHIFT); \
  83. if( iNewMipLevel > maxLevel ) \
  84. iNewMipLevel = maxLevel; \
  85. else \
  86. { \
  87. if( iNewMipLevel < 0 ) \
  88. iNewMipLevel = 0; \
  89. } \
  90. }
  91. #define FLUSH_DUE_TO_WRAP(par,vs) { if( vs ) pContext->flushWrap_##par = TRUE; }
  92. #define DONT_FLUSH_DUE_TO_WRAP(par,vs) { if( vs ) pContext->flushWrap_##par = FALSE; }
  93. #define RENDER_AREA_STIPPLE_ENABLE(a) a |= 1;
  94. #define RENDER_AREA_STIPPLE_DISABLE(a) a &= ~1;
  95. #define RENDER_LINE_STIPPLE_ENABLE(a) a |= (1 << 1);
  96. #define RENDER_LINE_STIPPLE_DISABLE(a) a &= ~(1 << 1);
  97. #define RENDER_TEXTURE_ENABLE(a) a |= (1 << 13);
  98. #define RENDER_TEXTURE_DISABLE(a) a &= ~(1 << 13);
  99. #define RENDER_FOG_ENABLE(a) a |= (1 << 14);
  100. #define RENDER_FOG_DISABLE(a) a &= ~(1 << 14);
  101. #define RENDER_SUB_PIXEL_CORRECTION_ENABLE(a) a |= (1 << 16);
  102. #define RENDER_SUB_PIXEL_CORRECTION_DISABLE(a) a &= ~(1 << 16);
  103. #define RENDER_LINE(a) a &= ~(1 << 6);
  104. // Disable line stipple when rendering trapezoid
  105. #define RENDER_TRAPEZOID(a) a = (a & ~(1 << 1)) | (1 << 6);
  106. #define RENDER_POINT(a) a = (a & ~(3 << 6)) | (2 << 6);
  107. #define RENDER_NEGATIVE_CULL_P3(a) a |= (1 << 17);
  108. #define RENDER_POSITIVE_CULL_P3(a) a &= ~(1 << 17);
  109. //*****************************************************
  110. // PERMEDIA3 HW DEFINITIONS WE NEED
  111. //*****************************************************
  112. #ifdef WNT_DDRAW
  113. // NT needs this for the functions it places in DDEnable, which
  114. // live in the mini directory for W95
  115. typedef struct {
  116. union {
  117. struct GlintReg Glint;
  118. };
  119. } *PREGISTERS;
  120. #define DEFAULT_SUBBUFFERS 8
  121. #else
  122. #define DEFAULT_SUBBUFFERS 128
  123. #endif // WNT_DDRAW
  124. // Macros to identify the Permedia3 chip type
  125. #define RENDERCHIP_P3RXFAMILY \
  126. (pThisDisplay->pGLInfo->dwRenderFamily == P3R3_ID)
  127. #define RENDERCHIP_PERMEDIAP3 \
  128. ((pThisDisplay->pGLInfo->dwRenderChipID == PERMEDIA3_ID) || \
  129. (pThisDisplay->pGLInfo->dwRenderChipID == GLINTR3_ID ))
  130. #define TLCHIP_GAMMA ( pThisDisplay->pGLInfo->dwGammaRev != 0)
  131. //@@BEGIN_DDKSPLIT
  132. //#define RENDERCHIP_PERMEDIAP2 ((pThisDisplay->pGLInfo->dwRenderChipID == PERMEDIA2_ID) || (pThisDisplay->pGLInfo->dwRenderChipID == TIPERMEDIA2_ID))
  133. //#define RENDERCHIP_PERMEDIAFAMILY (pThisDisplay->pGLInfo->dwRenderFamily == PERMEDIA_ID)
  134. //#define RENDERCHIP_PERMEDIAP4 (pThisDisplay->pGLInfo->dwRenderChipID == PERMEDIA4_ID)
  135. //#define RENDERCHIP_PERMEDIAPLUS (pThisDisplay->pGLInfo->dwRenderChipID == PERMEDIAPLUS_ID)
  136. //#define RENDERCHIP_PERMEDIAP2_ST_REV0 (pThisDisplay->pGLInfo->dwRenderChipRev == PERMEDIA2_REV0)
  137. //#define RENDERCHIP_PERMEDIAP2_ST_REV1 (pThisDisplay->pGLInfo->dwRenderChipRev == PERMEDIA2_REV1)
  138. //#define RENDERCHIP_PERMEDIAP2_ST (pThisDisplay->pGLInfo->dwRenderChipID == PERMEDIA2_ID)
  139. //#define RENDERCHIP_GLINTR3 (pThisDisplay->pGLInfo->dwRenderChipID == GLINTR3_ID)
  140. //#define RENDERCHIP_GLINTR4 (pThisDisplay->pGLInfo->dwRenderChipID == GLINTR4_ID)
  141. //#define TLCHIP_GAMMA1 (pThisDisplay->pGLInfo->dwRenderChipID == GAMMA_ID)
  142. //#define TLCHIP_GAMMA3 (pThisDisplay->pGLInfo->dwTLChipID == GAMMA3_ID)
  143. //#define TLCHIP_GAMMAFAMILY (pThisDisplay->pGLInfo->dwTLFamily == GAMMA_ID)
  144. //@@END_DDKSPLIT
  145. // Depth of FB in pixel size
  146. #define GLINTDEPTH8 0
  147. #define GLINTDEPTH16 1
  148. #define GLINTDEPTH32 2
  149. #define GLINTDEPTH24 4
  150. // Bits in the Render command
  151. #define __RENDER_VARIABLE_SPANS (1 << 18)
  152. #define __RENDER_SYNC_ON_HOST_DATA (1 << 12)
  153. #define __RENDER_SYNC_ON_BIT_MASK (1 << 11)
  154. #define __RENDER_TRAPEZOID_PRIMITIVE (__GLINT_TRAPEZOID_PRIMITIVE << 6)
  155. #define __RENDER_LINE_PRIMITIVE (__GLINT_LINE_PRIMITIVE << 6)
  156. #define __RENDER_POINT_PRIMITIVE (__GLINT_POINT_PRIMITIVE << 6)
  157. #define __RENDER_FAST_FILL_INC(n) (((n) >> 4) << 4) // n = 8, 16 or 32
  158. #define __RENDER_FAST_FILL_ENABLE (1 << 3)
  159. #define __RENDER_RESET_LINE_STIPPLE (1 << 2)
  160. #define __RENDER_LINE_STIPPLE_ENABLE (1 << 1)
  161. #define __RENDER_AREA_STIPPLE_ENABLE (1 << 0)
  162. #define __RENDER_TEXTURED_PRIMITIVE (1 << 13)
  163. // Some constants
  164. #define ONE 0x00010000
  165. // Macro to take a GLINT logical op and return the enabled LogcialOpMode bits
  166. #define GLINT_ENABLED_LOGICALOP(op) (((op) << 1) | __PERMEDIA_ENABLE)
  167. #if WNT_DDRAW
  168. // NT Calls to switch hardware contexts
  169. typedef enum COntextType_Tag {
  170. ContextType_None,
  171. ContextType_Fixed,
  172. ContetxType_RegisterList,
  173. ContextType_Dump
  174. } ContextType;
  175. extern VOID vGlintFreeContext(
  176. PPDEV ppdev,
  177. LONG ctxtId);
  178. extern LONG GlintAllocateNewContext(
  179. PPDEV ppdev,
  180. DWORD *pTag,
  181. LONG ntags,
  182. ULONG NumSubBuffers,
  183. PVOID priv,
  184. ContextType ctxtType);
  185. extern VOID vGlintSwitchContext(
  186. PPDEV ppdev,
  187. LONG ctxtId);
  188. // On NT Registry variables are stored as DWORDS.
  189. extern BOOL bGlintQueryRegistryValueUlong(PPDEV, LPWSTR, PULONG);
  190. #endif //WNT_DDRAW
  191. #endif //__DLTAMACR_H