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.

290 lines
13 KiB

  1. #include "rgb_pch.h"
  2. #pragma hdrstop
  3. namespace D3D8RGBRast
  4. {
  5. const D3DCAPS8 CRGBDriver::c_D3DCaps=
  6. {
  7. // Indicates this is software rasterizer.
  8. /*D3DDEVTYPE_HAL|| D3DDEVTYPE_REF||*/ D3DDEVTYPE_SW,
  9. // Adapter ordinal (isn't used to report anything).
  10. 0,
  11. // Caps (See ddraw.h & d3d8caps.h for details of each CAP).
  12. /*DDCAPS_3D| DDCAPS_ALIGNBOUNDARYDEST| DDCAPS_ALIGNSIZEDEST|
  13. DDCAPS_ALIGNBOUNDARYSRC| DDCAPS_ALIGNSIZESRC| DDCAPS_ALIGNSTRIDE|
  14. DDCAPS_BLT| DDCAPS_BLTQUEUE| DDCAPS_BLTFOURCC| DDCAPS_BLTSTRETCH|
  15. DDCAPS_GDI| DDCAPS_OVERLAY| DDCAPS_OVERLAYCANTCLIP| DDCAPS_OVERLAYFOURCC|
  16. DDCAPS_OVERLAYSTRETCH|*/ DDCAPS_PALETTE| /*DDCAPS_PALETTEVSYNC|
  17. DDCAPS_READSCANLINE| DDCAPS_VBI| DDCAPS_ZBLTS| DDCAPS_ZOVERLAYS|
  18. DDCAPS_COLORKEY| DDCAPS_ALPHA| DDCAPS_COLORKEYHWASSIST| DDCAPS_NOHARDWARE|
  19. DDCAPS_BLTCOLORFILL| DDCAPS_BANKSWITCHED| DDCAPS_BLTDEPTHFILL|
  20. DDCAPS_CANCLIP| DDCAPS_CANCLIPSTRETCHED| DDCAPS_CANBLTSYSMEM|
  21. D3DCAPS_READ_SCANLINE|*/ 0,
  22. // Caps2
  23. /*DDCAPS2_CERTIFIED| DDCAPS2_NO2DDURING3DSCENE| DDCAPS2_VIDEOPORT|
  24. DDCAPS2_AUTOFLIPOVERLAY| DDCAPS2_CANBOBINTERLEAVED|
  25. DDCAPS2_CANBOBNONINTERLEAVED| DDCAPS2_COLORCONTROLOVERLAY|
  26. DDCAPS2_COLORCONTROLPRIMARY|*/ DDCAPS2_CANDROPZ16BIT|
  27. /*DDCAPS2_NONLOCALVIDMEM| DDCAPS2_NONLOCALVIDMEMCAPS|
  28. DDCAPS2_NOPAGELOCKREQUIRED|*/ DDCAPS2_WIDESURFACES|
  29. /*DDCAPS2_CANFLIPODDEVEN| DDCAPS2_CANBOBHARDWARE| DDCAPS2_COPYFOURCC|
  30. DDCAPS2_PRIMARYGAMMA|*/ DDCAPS2_CANRENDERWINDOWED|
  31. /*DDCAPS2_CANCALIBRATEGAMMA| DDCAPS2_FLIPINTERVAL|
  32. DDCAPS2_FLIPNOVSYNC| DDCAPS2_CANMANAGETEXTURE|
  33. DDCAPS2_TEXMANINNONLOCALVIDMEM| DDCAPS2_STEREO|
  34. DDCAPS2_SYSTONONLOCAL_AS_SYSTOLOCAL| D3DCAPS2_NO2DDURING3DSCENE|
  35. D3DCAPS2_FULLSCREENGAMMA|*/ D3DCAPS2_CANRENDERWINDOWED|
  36. /*D3DCAPS2_CANCALIBRATEGAMMA|*/ 0,
  37. // Caps3
  38. 0,
  39. // Presentation Intervals
  40. 0,
  41. // Cursor Caps
  42. 0,
  43. // DevCaps (See d3d8caps.h & d3dhal.h)
  44. // The SDDI driver should keep D3DDEVCAPS_TEXTUREVIDEOMEMORY enabled. The
  45. // runtime does not behave correctly if the driver does not enable and
  46. // support this cap. In other words, all textures must be able to be
  47. // vid mem (driver allocated) textures, at least.
  48. D3DDEVCAPS_EXECUTESYSTEMMEMORY| /*D3DDEVCAPS_EXECUTEVIDEOMEMORY|*/
  49. D3DDEVCAPS_TLVERTEXSYSTEMMEMORY| /*D3DDEVCAPS_TLVERTEXVIDEOMEMORY|*/
  50. D3DDEVCAPS_TEXTURESYSTEMMEMORY| D3DDEVCAPS_TEXTUREVIDEOMEMORY|
  51. D3DDEVCAPS_DRAWPRIMTLVERTEX| /*D3DDEVCAPS_CANRENDERAFTERFLIP|
  52. D3DDEVCAPS_TEXTURENONLOCALVIDMEM|*/ D3DDEVCAPS_DRAWPRIMITIVES2|
  53. /*D3DDEVCAPS_SEPARATETEXTUREMEMORIES|*/ D3DDEVCAPS_DRAWPRIMITIVES2EX|
  54. /*D3DDEVCAPS_HWTRANSFORMANDLIGHT| D3DDEVCAPS_CANBLTSYSTONONLOCAL|
  55. D3DDEVCAPS_HWRASTERIZATION| D3DDEVCAPS_PUREDEVICE|
  56. D3DDEVCAPS_QUINTICRTPATCHES| D3DDEVCAPS_RTPATCHES|
  57. D3DDEVCAPS_RTPATCHHANDLEZERO| D3DDEVCAPS_NPATCHES|
  58. D3DDEVCAPS_HWVERTEXBUFFER| D3DDEVCAPS_HWINDEXBUFFER|*/ 0,
  59. // Primitive Misc Caps
  60. /*D3DPMISCCAPS_MASKZ| D3DPMISCCAPS_LINEPATTERNREP|*/ D3DPMISCCAPS_CULLNONE|
  61. D3DPMISCCAPS_CULLCW| D3DPMISCCAPS_CULLCCW| /*D3DPMISCCAPS_COLORWRITEENABLE|
  62. D3DPMISCCAPS_CLIPPLANESCALEDPOINTS| D3DPMISCCAPS_CLIPTLVERTS|
  63. D3DPMISCCAPS_TSSARGTEMP| D3DPMISCCAPS_BLENDOP|*/ 0,
  64. // Raster Caps
  65. D3DPRASTERCAPS_DITHER| D3DPRASTERCAPS_ROP2| D3DPRASTERCAPS_XOR|
  66. /*D3DPRASTERCAPS_PAT|*/ D3DPRASTERCAPS_ZTEST| D3DPRASTERCAPS_FOGVERTEX|
  67. D3DPRASTERCAPS_FOGTABLE| /*D3DPRASTERCAPS_ANTIALIASEDGES|*/
  68. D3DPRASTERCAPS_MIPMAPLODBIAS| /*D3DPRASTERCAPS_ZBIAS|
  69. D3DPRASTERCAPS_ZBUFFERLESSHSR|*/ D3DPRASTERCAPS_FOGRANGE|
  70. /*D3DPRASTERCAPS_ANISOTROPY| D3DPRASTERCAPS_WBUFFER|
  71. D3DPRASTERCAPS_WFOG| D3DPRASTERCAPS_ZFOG|
  72. D3DPRASTERCAPS_COLORPERSPECTIVE| D3DPRASTERCAPS_STRETCHBLTMULTISAMPLE|
  73. */ 0,
  74. // Z Compare Caps
  75. D3DPCMPCAPS_NEVER| D3DPCMPCAPS_LESS| D3DPCMPCAPS_EQUAL|
  76. D3DPCMPCAPS_LESSEQUAL| D3DPCMPCAPS_GREATER| D3DPCMPCAPS_NOTEQUAL|
  77. D3DPCMPCAPS_GREATEREQUAL| D3DPCMPCAPS_ALWAYS| 0,
  78. // Src Blend Caps
  79. D3DPBLENDCAPS_ZERO| D3DPBLENDCAPS_ONE| D3DPBLENDCAPS_SRCCOLOR|
  80. D3DPBLENDCAPS_INVSRCCOLOR| D3DPBLENDCAPS_SRCALPHA|
  81. D3DPBLENDCAPS_INVSRCALPHA| D3DPBLENDCAPS_DESTALPHA|
  82. D3DPBLENDCAPS_INVDESTALPHA| D3DPBLENDCAPS_DESTCOLOR|
  83. D3DPBLENDCAPS_INVDESTCOLOR| D3DPBLENDCAPS_SRCALPHASAT|
  84. D3DPBLENDCAPS_BOTHINVSRCALPHA| 0,
  85. // Dest Blend Caps
  86. D3DPBLENDCAPS_ZERO| D3DPBLENDCAPS_ONE| D3DPBLENDCAPS_SRCCOLOR|
  87. D3DPBLENDCAPS_INVSRCCOLOR| D3DPBLENDCAPS_SRCALPHA|
  88. D3DPBLENDCAPS_INVSRCALPHA| D3DPBLENDCAPS_DESTALPHA|
  89. D3DPBLENDCAPS_INVDESTALPHA| D3DPBLENDCAPS_DESTCOLOR|
  90. D3DPBLENDCAPS_INVDESTCOLOR| D3DPBLENDCAPS_SRCALPHASAT| 0,
  91. // Alpha Compare Caps
  92. D3DPCMPCAPS_NEVER| D3DPCMPCAPS_LESS| D3DPCMPCAPS_EQUAL|
  93. D3DPCMPCAPS_LESSEQUAL| D3DPCMPCAPS_GREATER| D3DPCMPCAPS_NOTEQUAL|
  94. D3DPCMPCAPS_GREATEREQUAL| D3DPCMPCAPS_ALWAYS| 0,
  95. // Shade Caps
  96. D3DPSHADECAPS_COLORGOURAUDRGB| D3DPSHADECAPS_SPECULARGOURAUDRGB|
  97. D3DPSHADECAPS_ALPHAGOURAUDBLEND| D3DPSHADECAPS_FOGGOURAUD| 0,
  98. // Texture Caps
  99. D3DPTEXTURECAPS_PERSPECTIVE| D3DPTEXTURECAPS_POW2|
  100. D3DPTEXTURECAPS_ALPHA| /*D3DPTEXTURECAPS_SQUAREONLY|*/
  101. D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE| D3DPTEXTURECAPS_ALPHAPALETTE|
  102. /*D3DPTEXTURECAPS_NONPOW2CONDITIONAL| D3DPTEXTURECAPS_PROJECTED|
  103. D3DPTEXTURECAPS_CUBEMAP| D3DPTEXTURECAPS_VOLUMEMAP|*/
  104. D3DPTEXTURECAPS_MIPMAP| /*D3DPTEXTURECAPS_MIPVOLUMEMAP|
  105. D3DPTEXTURECAPS_MIPCUBEMAP| D3DPTEXTURECAPS_CUBEMAP_POW2|
  106. D3DPTEXTURECAPS_VOLUMEMAP_POW2|*/ 0,
  107. // Texture Filter Caps
  108. D3DPTFILTERCAPS_MINFPOINT| D3DPTFILTERCAPS_MINFLINEAR|
  109. /*D3DPTFILTERCAPS_MINFANISOTROPIC|*/ D3DPTFILTERCAPS_MIPFPOINT|
  110. D3DPTFILTERCAPS_MIPFLINEAR| D3DPTFILTERCAPS_MAGFPOINT|
  111. D3DPTFILTERCAPS_MAGFLINEAR| /*D3DPTFILTERCAPS_MAGFANISOTROPIC|*/
  112. /*D3DPTFILTERCAPS_MAGFAFLATCUBIC| D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC|*/ 0,
  113. // Cube Texture Filter Caps
  114. /*D3DPTFILTERCAPS_MINFPOINT| D3DPTFILTERCAPS_MINFLINEAR|
  115. D3DPTFILTERCAPS_MINFANISOTROPIC| D3DPTFILTERCAPS_MIPFPOINT|
  116. D3DPTFILTERCAPS_MIPFLINEAR| D3DPTFILTERCAPS_MAGFPOINT|
  117. D3DPTFILTERCAPS_MAGFLINEAR| D3DPTFILTERCAPS_MAGFANISOTROPIC|
  118. D3DPTFILTERCAPS_MAGFAFLATCUBIC| D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC|*/ 0,
  119. // Volume Texture Filter Caps
  120. /*D3DPTFILTERCAPS_MINFPOINT| D3DPTFILTERCAPS_MINFLINEAR|
  121. D3DPTFILTERCAPS_MINFANISOTROPIC| D3DPTFILTERCAPS_MIPFPOINT|
  122. D3DPTFILTERCAPS_MIPFLINEAR| D3DPTFILTERCAPS_MAGFPOINT|
  123. D3DPTFILTERCAPS_MAGFLINEAR| D3DPTFILTERCAPS_MAGFANISOTROPIC|
  124. D3DPTFILTERCAPS_MAGFAFLATCUBIC| D3DPTFILTERCAPS_MAGFGAUSSIANCUBIC|*/ 0,
  125. // Texture Address Caps
  126. D3DPTADDRESSCAPS_WRAP| D3DPTADDRESSCAPS_MIRROR|
  127. D3DPTADDRESSCAPS_CLAMP| D3DPTADDRESSCAPS_BORDER|
  128. D3DPTADDRESSCAPS_INDEPENDENTUV| /*D3DPTADDRESSCAPS_MIRRORONCE|*/ 0,
  129. // Volume Texture Address Caps
  130. /*D3DPTADDRESSCAPS_WRAP| D3DPTADDRESSCAPS_MIRROR|
  131. D3DPTADDRESSCAPS_CLAMP| D3DPTADDRESSCAPS_BORDER|
  132. D3DPTADDRESSCAPS_INDEPENDENTUV| D3DPTADDRESSCAPS_MIRRORONCE|*/ 0,
  133. // Line Caps
  134. D3DLINECAPS_TEXTURE| D3DLINECAPS_ZTEST| D3DLINECAPS_BLEND|
  135. D3DLINECAPS_ALPHACMP| D3DLINECAPS_FOG| 0,
  136. // Max Texture Width, Height, Volume Extent
  137. 1024, 1024, 0,
  138. // Max Texture Repeat, Texture Aspect Ratio, Anisotropy
  139. 256, 0, 1,
  140. // Max VertexW
  141. 10000.0,
  142. // Guard Band left, top, right, bottom
  143. -4096.0f, -4096.0f, 4095.0f, 4095.0f,
  144. // Extents Adjust
  145. 0.0f,
  146. // Stencil Caps
  147. D3DSTENCILCAPS_KEEP| D3DSTENCILCAPS_ZERO| D3DSTENCILCAPS_REPLACE|
  148. D3DSTENCILCAPS_INCRSAT| D3DSTENCILCAPS_DECRSAT| D3DSTENCILCAPS_INVERT|
  149. D3DSTENCILCAPS_INCR| D3DSTENCILCAPS_DECR| 0,
  150. // FVF Caps
  151. (8& D3DFVFCAPS_TEXCOORDCOUNTMASK)| D3DFVFCAPS_DONOTSTRIPELEMENTS|
  152. D3DFVFCAPS_PSIZE| 0,
  153. // TextureOpCaps
  154. D3DTEXOPCAPS_DISABLE| D3DTEXOPCAPS_SELECTARG1| D3DTEXOPCAPS_SELECTARG2|
  155. D3DTEXOPCAPS_MODULATE| D3DTEXOPCAPS_MODULATE2X|
  156. D3DTEXOPCAPS_MODULATE4X| D3DTEXOPCAPS_ADD| D3DTEXOPCAPS_ADDSIGNED|
  157. /*D3DTEXOPCAPS_ADDSIGNED2X| D3DTEXOPCAPS_SUBTRACT|
  158. D3DTEXOPCAPS_ADDSMOOTH|*/ D3DTEXOPCAPS_BLENDDIFFUSEALPHA|
  159. D3DTEXOPCAPS_BLENDTEXTUREALPHA| D3DTEXOPCAPS_BLENDFACTORALPHA|
  160. D3DTEXOPCAPS_BLENDTEXTUREALPHAPM| /*D3DTEXOPCAPS_BLENDCURRENTALPHA|
  161. D3DTEXOPCAPS_PREMODULATE| D3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR|
  162. D3DTEXOPCAPS_MODULATECOLOR_ADDALPHA|
  163. D3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR|
  164. D3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA| D3DTEXOPCAPS_BUMPENVMAP|
  165. D3DTEXOPCAPS_BUMPENVMAPLUMINANCE| D3DTEXOPCAPS_DOTPRODUCT3|
  166. D3DTEXOPCAPS_MULTIPLYADD| D3DTEXOPCAPS_LERP|*/ 0,
  167. // Max Texture Blend Stages, Simulatenous Textures
  168. D3DHAL_TSS_MAXSTAGES, D3DHAL_TSS_MAXSTAGES,
  169. // Vertex Processing Caps
  170. /*D3DVTXPCAPS_TEXGEN| D3DVTXPCAPS_MATERIALSOURCE7|
  171. D3DVTXPCAPS_DIRECTIONALLIGHTS| D3DVTXPCAPS_POSITIONALLIGHTS|
  172. D3DVTXPCAPS_LOCALVIEWER| D3DVTXPCAPS_TWEENING|*/ 0,
  173. // Max Active Lights, User Clip Planes, Vertex Blend Matrices
  174. 0, 0, 0,
  175. // Max Vertex Blend Matrix Index, Point Size, Primitive Count
  176. 0, 128.0f, 0x0000FFFF,
  177. // Max Vertex Index, Streams, Stream Stride,
  178. 0x0000FFFF, 1, 256,
  179. // Vertex Shader version, Max Vertex Shader Const
  180. D3DVS_VERSION(0,0), 0,
  181. // Pixel Shader version, Max Pixel Shader Value
  182. D3DPS_VERSION(0,0), 16.0f,
  183. };
  184. CSupportedSurface CRGBDriver::c_aSurfaces[11];
  185. void InitSupportedSurface( CSupportedSurface& SS, const D3DFORMAT D3DFmt,
  186. CRGBSurfAllocator::TCreateSurfFn CFn,
  187. const bool bTexture, const bool bVolTexture, const bool bCubeTexture,
  188. const bool bOffScreenTarget, const bool bSameFmtTarget,
  189. const bool bZStencil, const bool bZStencilWithColor,
  190. const bool bSameFmtUpToAlpha, const bool b3DAccel,
  191. const DWORD dwPrivateFmtBitCount= 0, const WORD wFlipMSTypes= 0,
  192. const WORD wBltMSTypes= 0)
  193. {
  194. DDSURFACEDESC SDesc;
  195. ZeroMemory( &SDesc, sizeof( SDesc));
  196. SDesc.dwSize= sizeof( SDesc);
  197. DWORD dwOps( 0);
  198. if( bTexture) dwOps|= D3DFORMAT_OP_TEXTURE;
  199. if( bVolTexture) dwOps|= D3DFORMAT_OP_VOLUMETEXTURE;
  200. if( bCubeTexture) dwOps|= D3DFORMAT_OP_CUBETEXTURE;
  201. if( bOffScreenTarget) dwOps|= D3DFORMAT_OP_OFFSCREEN_RENDERTARGET;
  202. if( bSameFmtTarget) dwOps|= D3DFORMAT_OP_SAME_FORMAT_RENDERTARGET;
  203. if( bZStencil) dwOps|= D3DFORMAT_OP_ZSTENCIL;
  204. if( bZStencilWithColor) dwOps|= D3DFORMAT_OP_ZSTENCIL_WITH_ARBITRARY_COLOR_DEPTH;
  205. if( bSameFmtUpToAlpha) dwOps|= D3DFORMAT_OP_SAME_FORMAT_UP_TO_ALPHA_RENDERTARGET;
  206. if( b3DAccel) dwOps|= D3DFORMAT_OP_3DACCELERATION;
  207. SDesc.ddpfPixelFormat.dwFlags= DDPF_D3DFORMAT;
  208. SDesc.ddpfPixelFormat.dwFourCC= static_cast<DWORD>(D3DFmt);
  209. SDesc.ddpfPixelFormat.dwOperations= dwOps;
  210. SDesc.ddpfPixelFormat.dwPrivateFormatBitCount= dwPrivateFmtBitCount;
  211. SDesc.ddpfPixelFormat.MultiSampleCaps.wFlipMSTypes= wFlipMSTypes;
  212. SDesc.ddpfPixelFormat.MultiSampleCaps.wBltMSTypes= wBltMSTypes;
  213. SS= CSupportedSurface( SDesc, CFn);
  214. }
  215. void CRGBDriver::InitSupportedSurfaceArray( void)
  216. {
  217. // Tex, VTex, CTex, OffSTarg, SameFmtTarg, Z/S, Z/SWColor, SameFmtToA, 3D
  218. InitSupportedSurface( c_aSurfaces[ 0], D3DFMT_X1R5G5B5, CX1R5G5B5Surface::Create,
  219. true, false, false, false, false, false, false, false, false);
  220. InitSupportedSurface( c_aSurfaces[ 1], D3DFMT_A1R5G5B5, CA1R5G5B5Surface::Create,
  221. true, false, false, false, false, false, false, false, false);
  222. InitSupportedSurface( c_aSurfaces[ 2], D3DFMT_P8, CP8Surface::Create,
  223. true, false, false, false, false, false, false, false, false);
  224. InitSupportedSurface( c_aSurfaces[ 3], D3DFMT_L8, CL8Surface::Create,
  225. true, false, false, false, false, false, false, false, false);
  226. InitSupportedSurface( c_aSurfaces[ 4], D3DFMT_A8L8, CA8L8Surface::Create,
  227. true, false, false, false, false, false, false, false, false);
  228. InitSupportedSurface( c_aSurfaces[ 5], D3DFMT_A4R4G4B4, CA4R4G4B4Surface::Create,
  229. true, false, false, false, false, false, false, false, false);
  230. InitSupportedSurface( c_aSurfaces[ 6], D3DFMT_R5G6B5, CR5G6B5Surface::Create,
  231. true, false, false, true, true, false, false, false, true);
  232. InitSupportedSurface( c_aSurfaces[ 7], D3DFMT_A8R8G8B8, CA8R8G8B8Surface::Create,
  233. true, false, false, true, true, false, false, true, true);
  234. InitSupportedSurface( c_aSurfaces[ 8], D3DFMT_X8R8G8B8, CX8R8G8B8Surface::Create,
  235. true, false, false, true, true, false, false, false, true);
  236. InitSupportedSurface( c_aSurfaces[ 9], D3DFMT_D16_LOCKABLE, CD16Surface::Create,
  237. false, false, false, false, false, true, true, false, false);
  238. InitSupportedSurface( c_aSurfaces[10], D3DFMT_D24S8, CD24S8Surface::Create,
  239. false, false, false, false, false, true, true, false, false);
  240. };
  241. CRGBDriver::CRGBDriver() throw()
  242. :TSubDriver( c_aSurfaces,
  243. c_aSurfaces+ sizeof(c_aSurfaces)/ sizeof(c_aSurfaces[0]),
  244. TSurfAlloc( c_aSurfaces,
  245. c_aSurfaces+ sizeof(c_aSurfaces)/ sizeof(c_aSurfaces[0])) )
  246. { }
  247. }