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.

252 lines
8.3 KiB

  1. /******************************Module*Header**********************************\
  2. *
  3. * **************************
  4. * * DirectDraw SAMPLE CODE *
  5. * **************************
  6. *
  7. * Module Name: dddebug.c
  8. *
  9. * Content: some DDraw and D3D debug output functions
  10. *
  11. * Copyright (c) 1994-1998 3Dlabs Inc. Ltd. All rights reserved.
  12. * Copyright (c) 1995-1999 Microsoft Corporation. All rights reserved.
  13. \*****************************************************************************/
  14. #include "precomp.h"
  15. #include <windef.h>
  16. #include <limits.h>
  17. #include <stdio.h>
  18. #include <stdarg.h>
  19. #if (DBG)
  20. //-----------------------------------------------------------------------------
  21. //
  22. // DecodeBlend
  23. //
  24. // produce debug output for D3D blend modes
  25. //
  26. //-----------------------------------------------------------------------------
  27. VOID
  28. DecodeBlend( LONG Level, DWORD i )
  29. {
  30. switch ((D3DBLEND)i)
  31. {
  32. case D3DBLEND_ZERO:
  33. DISPDBG((Level, " ZERO"));
  34. break;
  35. case D3DBLEND_ONE:
  36. DISPDBG((Level, " ONE"));
  37. break;
  38. case D3DBLEND_SRCCOLOR:
  39. DISPDBG((Level, " SRCCOLOR"));
  40. break;
  41. case D3DBLEND_INVSRCCOLOR:
  42. DISPDBG((Level, " INVSRCCOLOR"));
  43. break;
  44. case D3DBLEND_SRCALPHA:
  45. DISPDBG((Level, " SRCALPHA"));
  46. break;
  47. case D3DBLEND_INVSRCALPHA:
  48. DISPDBG((Level, " INVSRCALPHA"));
  49. break;
  50. case D3DBLEND_DESTALPHA:
  51. DISPDBG((Level, " DESTALPHA"));
  52. break;
  53. case D3DBLEND_INVDESTALPHA:
  54. DISPDBG((Level, " INVDESTALPHA"));
  55. break;
  56. case D3DBLEND_DESTCOLOR:
  57. DISPDBG((Level, " DESTCOLOR"));
  58. break;
  59. case D3DBLEND_INVDESTCOLOR:
  60. DISPDBG((Level, " INVDESTCOLOR"));
  61. break;
  62. case D3DBLEND_SRCALPHASAT:
  63. DISPDBG((Level, " SRCALPHASAT"));
  64. break;
  65. case D3DBLEND_BOTHSRCALPHA:
  66. DISPDBG((Level, " BOTHSRCALPHA"));
  67. break;
  68. case D3DBLEND_BOTHINVSRCALPHA:
  69. DISPDBG((Level, " BOTHINVSRCALPHA"));
  70. break;
  71. }
  72. } /* DecodeBlend */
  73. // Surface dumping is turned on by setting DDDebugLevel
  74. LONG DDDebugLevel = 0;
  75. //-----------------------------------------------------------------------------
  76. //
  77. // DumpSurface
  78. //
  79. // dump properties of a DirectDraw Surface
  80. //
  81. //-----------------------------------------------------------------------------
  82. VOID
  83. DumpSurface(LONG Level,
  84. LPDDRAWI_DDRAWSURFACE_LCL lpDDSurface,
  85. LPDDSURFACEDESC lpDDSurfaceDesc)
  86. {
  87. LPDDRAWI_DDRAWSURFACE_GBL psurf_gbl;
  88. LPDDRAWI_DDRAWSURFACE_LCL psurf_lcl;
  89. LPDDPIXELFORMAT pPixFormat;
  90. DDSCAPS ddsCaps;
  91. DDSCAPSEX ddsCapsEx;
  92. memset( &ddsCaps, 0, sizeof(ddsCaps));
  93. memset( &ddsCapsEx, 0, sizeof(ddsCapsEx));
  94. if (Level <= DDDebugLevel)
  95. {
  96. Level = 0;
  97. DBG_DD((Level," Surface Dump:"));
  98. if (lpDDSurfaceDesc != NULL)
  99. {
  100. pPixFormat = &lpDDSurfaceDesc->ddpfPixelFormat;
  101. ddsCaps = lpDDSurfaceDesc->ddsCaps;
  102. DBG_DD((Level," Surface Width: 0x%x",
  103. lpDDSurfaceDesc->dwWidth));
  104. DBG_DD((Level," Surface Height: 0x%x",
  105. lpDDSurfaceDesc->dwHeight));
  106. DBG_DD((Level," dwFlags: 0x%x",
  107. lpDDSurfaceDesc->dwFlags));
  108. DBG_DD((Level," DestOverlay: dwColorSpaceLowValue: 0x%x",
  109. lpDDSurfaceDesc->ddckCKDestOverlay.dwColorSpaceLowValue));
  110. DBG_DD((Level," DestOverlay: dwColorSpaceHighValue: 0x%x",
  111. lpDDSurfaceDesc->ddckCKDestOverlay.dwColorSpaceHighValue));
  112. DBG_DD((Level," DestBlt: dwColorSpaceLowValue: 0x%x",
  113. lpDDSurfaceDesc->ddckCKDestBlt.dwColorSpaceLowValue));
  114. DBG_DD((Level," DestBlt: dwColorSpaceHighValue: 0x%x",
  115. lpDDSurfaceDesc->ddckCKDestBlt.dwColorSpaceHighValue));
  116. DBG_DD((Level," SrcOverlay: dwColorSpaceLowValue: 0x%x",
  117. lpDDSurfaceDesc->ddckCKSrcOverlay.dwColorSpaceLowValue));
  118. DBG_DD((Level," SrcOverlay: dwColorSpaceHighValue: 0x%x",
  119. lpDDSurfaceDesc->ddckCKSrcOverlay.dwColorSpaceHighValue));
  120. DBG_DD((Level," SrcBlt: dwColorSpaceLowValue: 0x%x",
  121. lpDDSurfaceDesc->ddckCKSrcBlt.dwColorSpaceLowValue));
  122. DBG_DD((Level," SrcBlt: dwColorSpaceHighValue: 0x%x",
  123. lpDDSurfaceDesc->ddckCKSrcBlt.dwColorSpaceHighValue));
  124. }
  125. else if (lpDDSurface != NULL)
  126. {
  127. psurf_gbl = lpDDSurface->lpGbl;
  128. psurf_lcl = lpDDSurface;
  129. pPixFormat = &psurf_gbl->ddpfSurface;
  130. ddsCaps = psurf_lcl->ddsCaps;
  131. ddsCapsEx= psurf_lcl->lpSurfMore->ddsCapsEx;
  132. DBG_DD((Level," Surface Width: 0x%x",
  133. psurf_gbl->wWidth));
  134. DBG_DD((Level," Surface Height: 0x%x",
  135. psurf_gbl->wHeight));
  136. DBG_DD((Level," ddsCaps.dwCaps: 0x%x",
  137. psurf_lcl->ddsCaps.dwCaps));
  138. DBG_DD((Level," dwFlags: 0x%x",
  139. psurf_lcl->dwFlags));
  140. }
  141. DBG_DD((Level," dwFourCC: 0x%x",
  142. pPixFormat->dwFourCC));
  143. DBG_DD((Level," dwRGBBitCount: 0x%x",
  144. pPixFormat->dwRGBBitCount));
  145. DBG_DD((Level," dwR/Y BitMask: 0x%x",
  146. pPixFormat->dwRBitMask));
  147. DBG_DD((Level," dwG/U BitMask: 0x%x",
  148. pPixFormat->dwGBitMask));
  149. DBG_DD((Level," dwB/V BitMask: 0x%x",
  150. pPixFormat->dwBBitMask));
  151. DBG_DD((Level," dwRGBAlphaBitMask: 0x%x",
  152. pPixFormat->dwRGBAlphaBitMask));
  153. DBG_DD((Level," Surface Is:"));
  154. if (ddsCaps.dwCaps & DDSCAPS_TEXTURE)
  155. {
  156. DBG_DD((Level," TEXTURE"));
  157. }
  158. if (ddsCaps.dwCaps & DDSCAPS_SYSTEMMEMORY)
  159. {
  160. DBG_DD((Level," SYSTEMMEMORY"));
  161. }
  162. if (ddsCaps.dwCaps & DDSCAPS_VIDEOMEMORY)
  163. {
  164. DBG_DD((Level," VIDEOMEMORY"));
  165. }
  166. if (ddsCaps.dwCaps & DDSCAPS_NONLOCALVIDMEM)
  167. {
  168. DBG_DD((Level," NONLOCALVIDMEM"));
  169. }
  170. if (ddsCaps.dwCaps & DDSCAPS_LOCALVIDMEM)
  171. {
  172. DBG_DD((Level," LOCALVIDMEM"));
  173. }
  174. if (ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
  175. {
  176. DBG_DD((Level," PRIMARYSURFACE"));
  177. }
  178. if (ddsCaps.dwCaps & DDSCAPS_OFFSCREENPLAIN)
  179. {
  180. DBG_DD((Level," OFFSCREEN_PLAIN"));
  181. }
  182. if (ddsCaps.dwCaps & DDSCAPS_FRONTBUFFER)
  183. {
  184. DBG_DD((Level," FRONT_BUFFER"));
  185. }
  186. if (ddsCaps.dwCaps & DDSCAPS_BACKBUFFER)
  187. {
  188. DBG_DD((Level," BACK_BUFFER"));
  189. }
  190. if (ddsCaps.dwCaps & DDSCAPS_COMPLEX)
  191. {
  192. DBG_DD((Level," COMPLEX"));
  193. }
  194. if (ddsCaps.dwCaps & DDSCAPS_FLIP)
  195. {
  196. DBG_DD((Level," FLIP"));
  197. }
  198. if (ddsCaps.dwCaps & DDSCAPS_MODEX)
  199. {
  200. DBG_DD((Level," MODEX"));
  201. }
  202. if (ddsCaps.dwCaps & DDSCAPS_ALLOCONLOAD)
  203. {
  204. DBG_DD((Level," ALLOCONLOAD"));
  205. }
  206. if (ddsCaps.dwCaps & DDSCAPS_LIVEVIDEO)
  207. {
  208. DBG_DD((Level," LIVEVIDEO"));
  209. }
  210. if (pPixFormat->dwFlags & DDPF_ZBUFFER)
  211. {
  212. DBG_DD((Level," Z BUFFER"));
  213. }
  214. if (pPixFormat->dwFlags & DDPF_ALPHAPIXELS)
  215. {
  216. DBG_DD((Level," ALPHAPIXELS"));
  217. }
  218. if (pPixFormat->dwFlags & DDPF_ALPHA)
  219. {
  220. DBG_DD((Level," ALPHA"));
  221. }
  222. if (pPixFormat->dwFlags & DDPF_ALPHAPREMULT)
  223. {
  224. DBG_DD((Level," ALPHAPREMULT"));
  225. }
  226. #if DX7_STEREO
  227. if (ddsCapsEx.dwCaps2 & DDSCAPS2_STEREOSURFACELEFT)
  228. {
  229. DBG_DD((Level," STEREOSURFACELEFT"));
  230. }
  231. #endif
  232. }
  233. } // DumpSurface
  234. #endif