VirtualBox

source: vbox/trunk/src/VBox/Additions/WINNT/Graphics/Video/disp/wddm/VBoxDispDbg.h@ 38930

Last change on this file since 38930 was 38930, checked in by vboxsync, 13 years ago

wddm/3d: more rendering fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 12.7 KB
Line 
1/* $Id: VBoxDispDbg.h 38930 2011-10-03 08:45:54Z vboxsync $ */
2
3/** @file
4 * VBoxVideo Display D3D User mode dll
5 */
6
7/*
8 * Copyright (C) 2011 Oracle Corporation
9 *
10 * This file is part of VirtualBox Open Source Edition (OSE), as
11 * available from http://www.virtualbox.org. This file is free software;
12 * you can redistribute it and/or modify it under the terms of the GNU
13 * General Public License (GPL) as published by the Free Software
14 * Foundation, in version 2 as it comes in the "COPYING" file of the
15 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
16 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
17 */
18
19#ifndef ___VBoxDispDbg_h__
20#define ___VBoxDispDbg_h__
21
22#ifdef DEBUG
23/* debugging configuration flags */
24
25/* generic debugging facilities & extra data checks */
26# define VBOXWDDMDISP_DEBUG
27# if defined(DEBUG_misha) || defined(DEBUG_leo)
28/* for some reason when debugging with VirtualKD, user-mode DbgPrint's are discarded
29 * the workaround so far is to pass the log info to the kernel driver and DbgPrint'ed from there,
30 * which is enabled by this define */
31//# define VBOXWDDMDISP_DEBUG_PRINTDRV
32/* use OutputDebugString */
33# define VBOXWDDMDISP_DEBUG_PRINT
34/* adds vectored exception handler to be able to catch non-debug UM exceptions in kernel debugger */
35# define VBOXWDDMDISP_DEBUG_VEHANDLER
36/* disable shared resource creation with wine */
37//# define VBOXWDDMDISP_DEBUG_NOSHARED
38# endif
39
40/* debug config vars */
41extern DWORD g_VBoxVDbgFDumpSetTexture;
42extern DWORD g_VBoxVDbgFDumpDrawPrim;
43extern DWORD g_VBoxVDbgFDumpTexBlt;
44extern DWORD g_VBoxVDbgFDumpBlt;
45extern DWORD g_VBoxVDbgFDumpRtSynch;
46extern DWORD g_VBoxVDbgFDumpFlush;
47extern DWORD g_VBoxVDbgFDumpShared;
48extern DWORD g_VBoxVDbgFDumpLock;
49extern DWORD g_VBoxVDbgFDumpUnlock;
50
51extern DWORD g_VBoxVDbgFBreakShared;
52extern DWORD g_VBoxVDbgFBreakDdi;
53
54
55/* log enable flags */
56extern DWORD g_VBoxVDbgFLogRel;
57extern DWORD g_VBoxVDbgFLog;
58extern DWORD g_VBoxVDbgFLogFlow;
59
60
61#endif
62
63#if 0
64# ifdef Assert
65# undef Assert
66# define Assert(_a) do{}while(0)
67# endif
68# ifdef AssertBreakpoint
69# undef AssertBreakpoint
70# define AssertBreakpoint() do{}while(0)
71# endif
72# ifdef AssertFailed
73# undef AssertFailed
74# define AssertFailed() do{}while(0)
75# endif
76#endif
77
78#ifdef VBOXWDDMDISP_DEBUG_VEHANDLER
79void vboxVDbgVEHandlerRegister();
80void vboxVDbgVEHandlerUnregister();
81#endif
82
83#ifdef VBOXWDDMDISP_DEBUG_PRINTDRV
84# define DbgPrintDrv(_m) do { vboxDispLogDrvF _m; } while (0)
85# define DbgPrintDrvRel(_m) do { vboxDispLogDrvF _m; } while (0)
86# define DbgPrintDrvFlow(_m) do { } while (0)
87#else
88# define DbgPrintDrv(_m) do { } while (0)
89# define DbgPrintDrvRel(_m) do { } while (0)
90# define DbgPrintDrvFlow(_m) do { } while (0)
91#endif
92
93#ifdef VBOXWDDMDISP_DEBUG_PRINT
94# define DbgPrintUsr(_m) do { vboxDispLogDbgPrintF _m; } while (0)
95# define DbgPrintUsrRel(_m) do { vboxDispLogDbgPrintF _m; } while (0)
96# define DbgPrintUsrFlow(_m) do { vboxDispLogDbgPrintF _m; } while (0)
97#else
98# define DbgPrintUsr(_m) do { } while (0)
99# define DbgPrintUsrRel(_m) do { } while (0)
100# define DbgPrintUsrFlow(_m) do { } while (0)
101#endif
102#ifdef DEBUG_misha
103# define WARN_BREAK() do { AssertFailed(); } while (0)
104#else
105# define WARN_BREAK() do { } while (0)
106#endif
107
108#ifdef VBOXWDDMDISP_DEBUG
109#define vboxVDbgInternalLog(_p) if (g_VBoxVDbgFLog) { _p }
110#define vboxVDbgInternalLogFlow(_p) if (g_VBoxVDbgFLogFlow) { _p }
111#define vboxVDbgInternalLogRel(_p) if (g_VBoxVDbgFLogRel) { _p }
112#else
113#define vboxVDbgInternalLog(_p) do {} while (0)
114#define vboxVDbgInternalLogFlow(_p) do {} while (0)
115#define vboxVDbgInternalLogRel(_p) do { _p } while (0)
116#endif
117
118#define WARN(_m) do { \
119 vboxVDbgInternalLog( \
120 Log(_m); \
121 DbgPrintUsr(_m); \
122 DbgPrintDrv(_m); \
123 ); \
124 WARN_BREAK(); \
125 } while (0)
126#define vboxVDbgPrint(_m) do { \
127 vboxVDbgInternalLog( \
128 Log(_m); \
129 DbgPrintUsr(_m); \
130 DbgPrintDrv(_m); \
131 ); \
132 } while (0)
133#define vboxVDbgPrintF(_m) do { \
134 vboxVDbgInternalLogFlow( \
135 LogFlow(_m); \
136 DbgPrintUsrFlow(_m); \
137 DbgPrintDrvFlow(_m); \
138 ); \
139 } while (0)
140#define vboxVDbgPrintR(_m) do { \
141 vboxVDbgInternalLogRel( \
142 LogRel(_m); \
143 DbgPrintUsrRel(_m); \
144 DbgPrintDrvRel(_m); \
145 ); \
146 } while (0)
147
148#ifdef VBOXWDDMDISP_DEBUG
149
150void vboxDispLogDrvF(char * szString, ...);
151void vboxDispLogDrv(char * szString);
152void vboxDispLogDbgPrintF(char * szString, ...);
153
154typedef struct VBOXWDDMDISP_ALLOCATION *PVBOXWDDMDISP_ALLOCATION;
155typedef struct VBOXWDDMDISP_RESOURCE *PVBOXWDDMDISP_RESOURCE;
156
157VOID vboxVDbgDoDumpSurfRectByAlloc(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, const RECT *pRect, const char* pSuffix);
158VOID vboxVDbgDoDumpAllocRect(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, const RECT *pRect, const char* pSuffix);
159VOID vboxVDbgDoDumpSurfRectByRc(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const RECT *pRect, const char* pSuffix);
160VOID vboxVDbgDoDumpSurfRect(const char * pPrefix, IDirect3DSurface9 *pSurf, const RECT *pRect, const char * pSuffix, bool bBreak);
161VOID vboxVDbgDoDumpSurf(const char * pPrefix, IDirect3DSurface9 *pSurf, const char * pSuffix);
162VOID vboxVDbgDoDumpRcRect(const char * pPrefix, IDirect3DResource9 *pRc, const RECT *pRect, const char * pSuffix);
163VOID vboxVDbgDoDumpRcRectByRc(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, const RECT *pRect, const char* pSuffix);
164VOID vboxVDbgDoDumpRcRectByAlloc(const char * pPrefix, const PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DResource9 *pD3DIf, const RECT *pRect, const char* pSuffix);
165VOID vboxVDbgDoDumpTex(const char * pPrefix, IDirect3DBaseTexture9 *pTexBase, const char * pSuffix);
166VOID vboxVDbgDoDumpRt(const char * pPrefix, struct VBOXWDDMDISP_DEVICE *pDevice, const char * pSuffix);
167
168void vboxVDbgDoPrintRect(const char * pPrefix, const RECT *pRect, const char * pSuffix);
169void vboxVDbgDoPrintAlloc(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const char * pSuffix);
170
171VOID vboxVDbgDoDumpLockSurfTex(const char * pPrefix, const D3DDDIARG_LOCK* pData, const char * pSuffix, bool fBreak);
172VOID vboxVDbgDoDumpUnlockSurfTex(const char * pPrefix, const D3DDDIARG_UNLOCK* pData, const char * pSuffix, bool fBreak);
173
174
175extern DWORD g_VBoxVDbgPid;
176#define VBOXVDBG_IS_PID(_pid) ((_pid) == (g_VBoxVDbgPid ? g_VBoxVDbgPid : (g_VBoxVDbgPid = GetCurrentProcessId())))
177#define VBOXVDBG_IS_DUMP_ALLOWED_PID(_pid) (((int)(_pid)) > 0 ? VBOXVDBG_IS_PID(_pid) : !VBOXVDBG_IS_PID(-((int)(_pid))))
178
179#define VBOXVDBG_IS_DUMP_ALLOWED(_type) ( \
180 g_VBoxVDbgFDump##_type \
181 && (g_VBoxVDbgFDump##_type == 1 \
182 || VBOXVDBG_IS_DUMP_ALLOWED_PID(g_VBoxVDbgFDump##_type) \
183 ) \
184 )
185
186#define VBOXVDBG_IS_BREAK_ALLOWED(_type) ( \
187 g_VBoxVDbgFBreak##_type \
188 && (g_VBoxVDbgFBreak##_type == 1 \
189 || VBOXVDBG_IS_DUMP_ALLOWED_PID(g_VBoxVDbgFBreak##_type) \
190 ) \
191 )
192
193#define VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pRc) (\
194 (_pRc)->RcDesc.fFlags.SharedResource \
195 && VBOXVDBG_IS_DUMP_ALLOWED(Shared) \
196 )
197
198#define VBOXVDBG_IS_BREAK_SHARED_ALLOWED(_pRc) (\
199 (_pRc)->RcDesc.fFlags.SharedResource \
200 && VBOXVDBG_IS_BREAK_ALLOWED(Shared) \
201 )
202
203#define VBOXVDBG_BREAK_SHARED(_pRc) do { \
204 if (VBOXVDBG_IS_BREAK_SHARED_ALLOWED(_pRc)) { \
205 vboxVDbgPrint(("Break on shared access: Rc(0x%p), SharedHandle(0x%p)\n", (_pRc), (_pRc)->aAllocations[0].hSharedHandle)); \
206 AssertFailed(); \
207 } \
208 } while (0)
209
210#define VBOXVDBG_BREAK_DDI() do { \
211 if (VBOXVDBG_IS_BREAK_ALLOWED(Ddi)) { \
212 AssertFailed(); \
213 } \
214 } while (0)
215
216#define VBOXVDBG_DUMP_DRAWPRIM_ENTER(_pDevice) do { \
217 if (VBOXVDBG_IS_DUMP_ALLOWED(DrawPrim)) \
218 { \
219 vboxVDbgDoDumpRt("==>"__FUNCTION__": RenderTarget Dump\n", (_pDevice), "\n"); \
220 }\
221 } while (0)
222
223#define VBOXVDBG_DUMP_DRAWPRIM_LEAVE(_pDevice) do { \
224 if (VBOXVDBG_IS_DUMP_ALLOWED(DrawPrim)) \
225 { \
226 vboxVDbgDoDumpRt("<=="__FUNCTION__": RenderTarget Dump\n", (_pDevice), "\n"); \
227 }\
228 } while (0)
229
230#define VBOXVDBG_DUMP_SETTEXTURE(_pRc) do { \
231 if (VBOXVDBG_IS_DUMP_ALLOWED(SetTexture) \
232 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pRc) \
233 ) \
234 { \
235 vboxVDbgDoDumpRcRectByRc("== "__FUNCTION__": ", _pRc, NULL, "\n"); \
236 } \
237 } while (0)
238
239#define VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { \
240 if (VBOXVDBG_IS_DUMP_ALLOWED(TexBlt) \
241 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pSrcRc) \
242 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pDstRc) \
243 ) \
244 { \
245 RECT _DstRect; \
246 vboxWddmRectMoved(&_DstRect, (_pSrcRect), (_pDstPoint)->x, (_pDstPoint)->y); \
247 vboxVDbgDoDumpRcRectByRc("==>"__FUNCTION__" Src: ", (_pSrcRc), (_pSrcRect), "\n"); \
248 vboxVDbgDoDumpRcRectByRc("==>"__FUNCTION__" Dst: ", (_pDstRc), &_DstRect, "\n"); \
249 } \
250 } while (0)
251
252#define VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { \
253 if (VBOXVDBG_IS_DUMP_ALLOWED(TexBlt) \
254 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pSrcRc) \
255 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pDstRc) \
256 ) \
257 { \
258 RECT _DstRect; \
259 vboxWddmRectMoved(&_DstRect, (_pSrcRect), (_pDstPoint)->x, (_pDstPoint)->y); \
260 vboxVDbgDoDumpRcRectByRc("<=="__FUNCTION__" Src: ", (_pSrcRc), (_pSrcRect), "\n"); \
261 vboxVDbgDoDumpRcRectByRc("<=="__FUNCTION__" Dst: ", (_pDstRc), &_DstRect, "\n"); \
262 } \
263 } while (0)
264
265#define VBOXVDBG_DUMP_BLT_ENTER(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { \
266 if (VBOXVDBG_IS_DUMP_ALLOWED(Blt) \
267 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED((_pSrcAlloc)->pRc) \
268 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED((_pDstAlloc)->pRc) \
269 ) \
270 { \
271 vboxVDbgDoDumpRcRectByAlloc("==>"__FUNCTION__" Src: ", (_pSrcAlloc), (_pSrcSurf), (_pSrcRect), "\n"); \
272 vboxVDbgDoDumpRcRectByAlloc("==>"__FUNCTION__" Dst: ", (_pDstAlloc), (_pDstSurf), (_pDstRect), "\n"); \
273 } \
274 } while (0)
275
276#define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { \
277 if (VBOXVDBG_IS_DUMP_ALLOWED(Blt) \
278 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED((_pSrcAlloc)->pRc) \
279 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED((_pDstAlloc)->pRc) \
280 ) \
281 { \
282 vboxVDbgDoDumpRcRectByAlloc("<=="__FUNCTION__" Src: ", (_pSrcAlloc), (_pSrcSurf), (_pSrcRect), "\n"); \
283 vboxVDbgDoDumpRcRectByAlloc("<=="__FUNCTION__" Dst: ", (_pDstAlloc), (_pDstSurf), (_pDstRect), "\n"); \
284 } \
285 } while (0)
286
287#define VBOXVDBG_DUMP_SYNC_RT(_pBbSurf) do { \
288 if (VBOXVDBG_IS_DUMP_ALLOWED(RtSynch)) \
289 { \
290 vboxVDbgDoDumpSurfRect("== "__FUNCTION__" Bb:\n", (_pBbSurf), NULL, "\n", true); \
291 } \
292 } while (0)
293
294#define VBOXVDBG_DUMP_FLUSH(_pDevice) do { \
295 if (VBOXVDBG_IS_DUMP_ALLOWED(Flush)) \
296 { \
297 vboxVDbgDoDumpRt("== "__FUNCTION__": RenderTarget Dump\n", (_pDevice), "\n"); \
298 }\
299 } while (0)
300
301#define VBOXVDBG_DUMP_LOCK_ST(_pData) do { \
302 if (VBOXVDBG_IS_DUMP_ALLOWED(Lock) \
303 || VBOXVDBG_IS_DUMP_ALLOWED(Unlock) \
304 ) \
305 { \
306 vboxVDbgDoDumpLockSurfTex("== "__FUNCTION__": ", (_pData), "\n", VBOXVDBG_IS_DUMP_ALLOWED(Lock)); \
307 } \
308 } while (0)
309
310#define VBOXVDBG_DUMP_UNLOCK_ST(_pData) do { \
311 if (VBOXVDBG_IS_DUMP_ALLOWED(Unlock) \
312 ) \
313 { \
314 vboxVDbgDoDumpUnlockSurfTex("== "__FUNCTION__": ", (_pData), "\n", true); \
315 } \
316 } while (0)
317
318#else
319#define VBOXVDBG_DUMP_DRAWPRIM_ENTER(_pDevice) do { } while (0)
320#define VBOXVDBG_DUMP_DRAWPRIM_LEAVE(_pDevice) do { } while (0)
321#define VBOXVDBG_DUMP_SETTEXTURE(_pRc) do { } while (0)
322#define VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { } while (0)
323#define VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { } while (0)
324#define VBOXVDBG_DUMP_BLT_ENTER(_pSrcRc, _pSrcSurf, _pSrcRect, _pDstRc, _pDstSurf, _pDstRect) do { } while (0)
325#define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcRc, _pSrcSurf, _pSrcRect, _pDstRc, _pDstSurf, _pDstRect) do { } while (0)
326#define VBOXVDBG_DUMP_SYNC_RT(_pBbSurf) do { } while (0)
327#define VBOXVDBG_DUMP_FLUSH(_pDevice) do { } while (0)
328#define VBOXVDBG_DUMP_LOCK_ST(_pData) do { } while (0)
329#define VBOXVDBG_DUMP_UNLOCK_ST(_pData) do { } while (0)
330#define VBOXVDBG_BREAK_SHARED(_pRc) do { } while (0)
331#define VBOXVDBG_BREAK_DDI() do { } while (0)
332#endif
333
334
335#endif /* #ifndef ___VBoxDispDbg_h__ */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette