VirtualBox

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

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

wddm/3d: enhanced logging

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.2 KB
Line 
1/* $Id: VBoxDispDbg.h 41472 2012-05-29 07:12:42Z 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#define VBOX_VIDEO_LOG_NAME "VBoxD3D"
23#define VBOX_VIDEO_LOG_LOGGER vboxVDbgInternalLogLogger
24#define VBOX_VIDEO_LOGREL_LOGGER vboxVDbgInternalLogRelLogger
25#define VBOX_VIDEO_LOGFLOW_LOGGER vboxVDbgInternalLogFlowLogger
26#define VBOX_VIDEO_LOG_FN_FMT "%s"
27
28#include "../../common/VBoxVideoLog.h"
29
30#ifdef DEBUG
31/* debugging configuration flags */
32
33/* generic debugging facilities & extra data checks */
34# define VBOXWDDMDISP_DEBUG
35# if defined(DEBUG_misha) || defined(DEBUG_leo)
36/* for some reason when debugging with VirtualKD, user-mode DbgPrint's are discarded
37 * the workaround so far is to pass the log info to the kernel driver and DbgPrint'ed from there,
38 * which is enabled by this define */
39//# define VBOXWDDMDISP_DEBUG_PRINTDRV
40/* use OutputDebugString */
41//# define VBOXWDDMDISP_DEBUG_PRINT
42/* adds vectored exception handler to be able to catch non-debug UM exceptions in kernel debugger */
43//# define VBOXWDDMDISP_DEBUG_VEHANDLER
44/* disable shared resource creation with wine */
45//# define VBOXWDDMDISP_DEBUG_NOSHARED
46# endif
47
48/* debug config vars */
49extern DWORD g_VBoxVDbgFDumpSetTexture;
50extern DWORD g_VBoxVDbgFDumpDrawPrim;
51extern DWORD g_VBoxVDbgFDumpTexBlt;
52extern DWORD g_VBoxVDbgFDumpBlt;
53extern DWORD g_VBoxVDbgFDumpRtSynch;
54extern DWORD g_VBoxVDbgFDumpFlush;
55extern DWORD g_VBoxVDbgFDumpShared;
56extern DWORD g_VBoxVDbgFDumpLock;
57extern DWORD g_VBoxVDbgFDumpUnlock;
58extern DWORD g_VBoxVDbgFDumpPresentEnter;
59extern DWORD g_VBoxVDbgFDumpPresentLeave;
60extern DWORD g_VBoxVDbgFDumpScSync;
61
62extern DWORD g_VBoxVDbgFBreakShared;
63extern DWORD g_VBoxVDbgFBreakDdi;
64
65extern DWORD g_VBoxVDbgFCheckSysMemSync;
66extern DWORD g_VBoxVDbgFCheckBlt;
67extern DWORD g_VBoxVDbgFCheckTexBlt;
68extern DWORD g_VBoxVDbgFCheckScSync;
69
70extern DWORD g_VBoxVDbgFSkipCheckTexBltDwmWndUpdate;
71
72/* log enable flags */
73extern DWORD g_VBoxVDbgFLogRel;
74extern DWORD g_VBoxVDbgFLog;
75extern DWORD g_VBoxVDbgFLogFlow;
76
77extern DWORD g_VBoxVDbgFIsModuleNameInited;
78extern char g_VBoxVDbgModuleName[];
79
80extern LONG g_VBoxVDbgFIsDwm;
81
82extern DWORD g_VBoxVDbgCfgMaxDirectRts;
83extern DWORD g_VBoxVDbgCfgForceDummyDevCreate;
84
85extern struct VBOXWDDMDISP_DEVICE *g_VBoxVDbgInternalDevice;
86extern struct VBOXWDDMDISP_RESOURCE *g_VBoxVDbgInternalRc;
87
88extern DWORD g_VBoxVDbgCfgCreateSwapchainOnDdiOnce;
89
90#endif
91
92#if 0
93# ifdef Assert
94# undef Assert
95# define Assert(_a) do{}while(0)
96# endif
97# ifdef AssertBreakpoint
98# undef AssertBreakpoint
99# define AssertBreakpoint() do{}while(0)
100# endif
101# ifdef AssertFailed
102# undef AssertFailed
103# define AssertFailed() do{}while(0)
104# endif
105#endif
106
107#ifdef VBOXWDDMDISP_DEBUG_VEHANDLER
108void vboxVDbgVEHandlerRegister();
109void vboxVDbgVEHandlerUnregister();
110#endif
111
112#if defined(LOG_TO_BACKDOOR_DRV) || defined(VBOXWDDMDISP_DEBUG_PRINTDRV)
113# define DbgPrintDrv(_m) do { vboxDispLogDrvF _m; } while (0)
114# define DbgPrintDrvRel(_m) do { vboxDispLogDrvF _m; } while (0)
115# define DbgPrintDrvFlow(_m) do { vboxDispLogDrvF _m; } while (0)
116#else
117# define DbgPrintDrv(_m) do { } while (0)
118# define DbgPrintDrvRel(_m) do { } while (0)
119# define DbgPrintDrvFlow(_m) do { } while (0)
120#endif
121
122#ifdef VBOXWDDMDISP_DEBUG_PRINT
123# define DbgPrintUsr(_m) do { vboxDispLogDbgPrintF _m; } while (0)
124# define DbgPrintUsrRel(_m) do { vboxDispLogDbgPrintF _m; } while (0)
125# define DbgPrintUsrFlow(_m) do { vboxDispLogDbgPrintF _m; } while (0)
126#else
127# define DbgPrintUsr(_m) do { } while (0)
128# define DbgPrintUsrRel(_m) do { } while (0)
129# define DbgPrintUsrFlow(_m) do { } while (0)
130#endif
131
132#ifdef VBOXWDDMDISP_DEBUG
133#define vboxVDbgInternalLog(_p) if (g_VBoxVDbgFLog) { _p }
134#define vboxVDbgInternalLogFlow(_p) if (g_VBoxVDbgFLogFlow) { _p }
135#define vboxVDbgInternalLogRel(_p) if (g_VBoxVDbgFLogRel) { _p }
136#else
137#define vboxVDbgInternalLog(_p) do {} while (0)
138#define vboxVDbgInternalLogFlow(_p) do {} while (0)
139#define vboxVDbgInternalLogRel(_p) do { _p } while (0)
140#endif
141
142/* @todo: remove these from the code and from here */
143#define vboxVDbgPrint(_m) LOG_EXACT(_m)
144#define vboxVDbgPrintF(_m) LOGF_EXACT(_m)
145#define vboxVDbgPrintR(_m) LOGREL_EXACT(_m)
146
147#define vboxVDbgInternalLogLogger(_m) do { \
148 vboxVDbgInternalLog( \
149 Log(_m); \
150 DbgPrintUsr(_m); \
151 DbgPrintDrv(_m); \
152 ); \
153 } while (0)
154
155#define vboxVDbgInternalLogFlowLogger(_m) do { \
156 vboxVDbgInternalLogFlow( \
157 LogFlow(_m); \
158 DbgPrintUsrFlow(_m); \
159 DbgPrintDrvFlow(_m); \
160 ); \
161 } while (0)
162
163#define vboxVDbgInternalLogRelLogger(_m) do { \
164 vboxVDbgInternalLogRel( \
165 LogRel(_m); \
166 DbgPrintUsrRel(_m); \
167 DbgPrintDrvRel(_m); \
168 ); \
169 } while (0)
170
171#if defined(VBOXWDDMDISP_DEBUG) || defined(LOG_TO_BACKDOOR_DRV)
172
173#define VBOXVDBG_STRCASE(_t) \
174 case _t: return #_t;
175#define VBOXVDBG_STRCASE_UNKNOWN() \
176 default: Assert(0); return "Unknown";
177
178static DECLINLINE(const char*) vboxDispLogD3DRcType(D3DRESOURCETYPE enmType)
179{
180 switch (enmType)
181 {
182 VBOXVDBG_STRCASE(D3DRTYPE_SURFACE);
183 VBOXVDBG_STRCASE(D3DRTYPE_VOLUME);
184 VBOXVDBG_STRCASE(D3DRTYPE_TEXTURE);
185 VBOXVDBG_STRCASE(D3DRTYPE_VOLUMETEXTURE);
186 VBOXVDBG_STRCASE(D3DRTYPE_CUBETEXTURE);
187 VBOXVDBG_STRCASE(D3DRTYPE_VERTEXBUFFER);
188 VBOXVDBG_STRCASE(D3DRTYPE_INDEXBUFFER);
189 VBOXVDBG_STRCASE_UNKNOWN();
190 }
191}
192
193#include "VBoxDispMpLogger.h"
194
195VBOXDISPMPLOGGER_DECL(void) VBoxDispMpLoggerDumpD3DCAPS9(struct _D3DCAPS9 *pCaps);
196
197void vboxDispLogDrvF(char * szString, ...);
198
199# define vboxDispDumpD3DCAPS9(_pCaps) do { VBoxDispMpLoggerDumpD3DCAPS9(_pCaps); } while (0)
200#else
201# define vboxDispDumpD3DCAPS9(_pCaps) do { } while (0)
202#endif
203
204#ifdef VBOXWDDMDISP_DEBUG
205
206void vboxDispLogDbgPrintF(char * szString, ...);
207
208typedef struct VBOXWDDMDISP_ALLOCATION *PVBOXWDDMDISP_ALLOCATION;
209typedef struct VBOXWDDMDISP_RESOURCE *PVBOXWDDMDISP_RESOURCE;
210
211/* functions all dump finally comes to */
212#define VBOXVDBG_DUMP_TYPEF_FLOW 0x00000001
213#define VBOXVDBG_DUMP_TYPEF_CONTENTS 0x00000002
214#define VBOXVDBG_DUMP_TYPEF_DONT_BREAK_ON_CONTENTS 0x00000004
215#define VBOXVDBG_DUMP_TYPEF_BREAK_ON_FLOW 0x00000008
216
217#define VBOXVDBG_DUMP_FLAGS_IS_SETANY(_fFlags, _Value) (((_fFlags) & (_Value)) != 0)
218#define VBOXVDBG_DUMP_FLAGS_IS_SET(_fFlags, _Value) (((_fFlags) & (_Value)) == (_Value))
219#define VBOXVDBG_DUMP_FLAGS_IS_CLEARED(_fFlags, _Value) (((_fFlags) & (_Value)) == 0)
220#define VBOXVDBG_DUMP_FLAGS_CLEAR(_fFlags, _Value) ((_fFlags) & (~(_Value)))
221#define VBOXVDBG_DUMP_FLAGS_SET(_fFlags, _Value) ((_fFlags) | (_Value))
222
223#define VBOXVDBG_DUMP_TYPE_ENABLED(_fFlags) (VBOXVDBG_DUMP_FLAGS_IS_SETANY(_fFlags, VBOXVDBG_DUMP_TYPEF_FLOW | VBOXVDBG_DUMP_TYPEF_CONTENTS))
224#define VBOXVDBG_DUMP_TYPE_FLOW_ONLY(_fFlags) (VBOXVDBG_DUMP_FLAGS_IS_SET(_fFlags, VBOXVDBG_DUMP_TYPEF_FLOW) \
225 && VBOXVDBG_DUMP_FLAGS_IS_CLEARED(_fFlags, VBOXVDBG_DUMP_TYPEF_CONTENTS))
226#define VBOXVDBG_DUMP_TYPE_CONTENTS(_fFlags) (VBOXVDBG_DUMP_FLAGS_IS_SET(_fFlags, VBOXVDBG_DUMP_TYPEF_CONTENTS))
227#define VBOXVDBG_DUMP_TYPE_GET_FLOW_ONLY(_fFlags) ( \
228 VBOXVDBG_DUMP_FLAGS_SET( \
229 VBOXVDBG_DUMP_FLAGS_CLEAR(_fFlags, VBOXVDBG_DUMP_TYPEF_CONTENTS), \
230 VBOXVDBG_DUMP_TYPEF_FLOW) \
231 )
232
233VOID vboxVDbgDoDumpAllocRect(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, RECT *pRect, const char* pSuffix, DWORD fFlags);
234VOID vboxVDbgDoDumpRcRect(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DResource9 *pD3DRc, RECT *pRect, const char * pSuffix, DWORD fFlags);
235VOID vboxVDbgDoDumpLockUnlockSurfTex(const char * pPrefix, const PVBOXWDDMDISP_ALLOCATION pAlloc, const char * pSuffix, DWORD fFlags);
236/* */
237
238VOID vboxVDbgDoDumpRt(const char * pPrefix, struct VBOXWDDMDISP_DEVICE *pDevice, const char * pSuffix, DWORD fFlags);
239VOID vboxVDbgDoDumpBb(const char * pPrefix, IDirect3DSwapChain9 *pSwapchainIf, const char * pSuffix, DWORD fFlags);
240VOID vboxVDbgDoDumpFb(const char * pPrefix, IDirect3DSwapChain9 *pSwapchainIf, const char * pSuffix, DWORD fFlags);
241
242void vboxVDbgDoPrintRect(const char * pPrefix, const RECT *pRect, const char * pSuffix);
243void vboxVDbgDoPrintAlloc(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const char * pSuffix);
244
245VOID vboxVDbgDoDumpLockSurfTex(const char * pPrefix, const D3DDDIARG_LOCK* pData, const char * pSuffix, DWORD fFlags);
246VOID vboxVDbgDoDumpUnlockSurfTex(const char * pPrefix, const D3DDDIARG_UNLOCK* pData, const char * pSuffix, DWORD fFlags);
247
248BOOL vboxVDbgDoCheckRectsMatch(const PVBOXWDDMDISP_RESOURCE pDstRc, uint32_t iDstAlloc,
249 const PVBOXWDDMDISP_RESOURCE pSrcRc, uint32_t iSrcAlloc,
250 const RECT *pDstRect,
251 const RECT *pSrcRect,
252 BOOL fBreakOnMismatch);
253
254BOOL vboxVDbgDoCheckExe(const char * pszName);
255
256VOID vboxVDbgDoPrintLopLastCmd(const char* pszDesc);
257
258extern DWORD g_VBoxVDbgPid;
259#define VBOXVDBG_IS_PID(_pid) ((_pid) == (g_VBoxVDbgPid ? g_VBoxVDbgPid : (g_VBoxVDbgPid = GetCurrentProcessId())))
260#define VBOXVDBG_IS_DUMP_ALLOWED_PID(_pid) (((int)(_pid)) > 0 ? VBOXVDBG_IS_PID(_pid) : !VBOXVDBG_IS_PID(-((int)(_pid))))
261
262#define VBOXVDBG_CHECK_EXE(_pszName) (vboxVDbgDoCheckExe(_pszName))
263#define VBOXVDBG_IS_DWM() (!!(g_VBoxVDbgFIsDwm >=0 ? g_VBoxVDbgFIsDwm : (g_VBoxVDbgFIsDwm = VBOXVDBG_CHECK_EXE("dwm.exe"))))
264
265#define VBOXVDBG_ASSERT_IS_DWM(_bDwm) do { \
266 Assert((!VBOXVDBG_IS_DWM()) == (!(_bDwm))); \
267 } while (0)
268
269#define VBOXVDBG_DUMP_FLAGS_FOR_TYPE(_type) g_VBoxVDbgFDump##_type
270#define VBOXVDBG_BREAK_FLAGS_FOR_TYPE(_type) g_VBoxVDbgFBreak##_type
271#define VBOXVDBG_CHECK_FLAGS_FOR_TYPE(_type) g_VBoxVDbgFCheck##_type
272#define VBOXVDBG_IS_DUMP_ALLOWED(_type) ( VBOXVDBG_DUMP_TYPE_ENABLED(VBOXVDBG_DUMP_FLAGS_FOR_TYPE(_type)) )
273
274#define VBOXVDBG_IS_BREAK_ALLOWED(_type) ( !!VBOXVDBG_BREAK_FLAGS_FOR_TYPE(_type) )
275
276#define VBOXVDBG_IS_CHECK_ALLOWED(_type) ( !!VBOXVDBG_CHECK_FLAGS_FOR_TYPE(_type) )
277
278#define VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pRc) (\
279 (_pRc)->RcDesc.fFlags.SharedResource \
280 && VBOXVDBG_IS_DUMP_ALLOWED(Shared) \
281 )
282
283#define VBOXVDBG_IS_BREAK_SHARED_ALLOWED(_pRc) (\
284 (_pRc)->RcDesc.fFlags.SharedResource \
285 && VBOXVDBG_IS_BREAK_ALLOWED(Shared) \
286 )
287
288#define VBOXVDBG_BREAK_SHARED(_pRc) do { \
289 if (VBOXVDBG_IS_BREAK_SHARED_ALLOWED(_pRc)) { \
290 vboxVDbgPrint(("Break on shared access: Rc(0x%p), SharedHandle(0x%p)\n", (_pRc), (_pRc)->aAllocations[0].hSharedHandle)); \
291 AssertFailed(); \
292 } \
293 } while (0)
294
295#define VBOXVDBG_BREAK_DDI() do { \
296 if (VBOXVDBG_IS_BREAK_ALLOWED(Ddi)) { \
297 AssertFailed(); \
298 } \
299 } while (0)
300
301#define VBOXVDBG_LOOP_LAST() do { vboxVDbgLoop = 0; } while (0)
302
303#define VBOXVDBG_LOOP(_op) do { \
304 DWORD vboxVDbgLoop = 1; \
305 do { \
306 _op; \
307 } while (vboxVDbgLoop); \
308 } while (0)
309
310#define VBOXVDBG_CHECK_SMSYNC(_pRc) do { \
311 if (VBOXVDBG_IS_CHECK_ALLOWED(SysMemSync)) { \
312 vboxWddmDbgRcSynchMemCheck((_pRc)); \
313 } \
314 } while (0)
315
316#define VBOXVDBG_DUMP_RECTS_INIT(_d) DWORD vboxVDbgDumpRects = _d;
317#define VBOXVDBG_DUMP_RECTS_FORCE() vboxVDbgDumpRects = 1;
318#define VBOXVDBG_DUMP_RECTS_FORCED() (!!vboxVDbgDumpRects)
319
320#define VBOXVDBG_CHECK_RECTS(_opRests, _opDump, _pszOpName, _pDstRc, _iDstAlloc, _pSrcRc, _iSrcAlloc, _pDstRect, _pSrcRect) do { \
321 VBOXVDBG_LOOP(\
322 VBOXVDBG_DUMP_RECTS_INIT(0); \
323 _opRests; \
324 if (vboxVDbgDoCheckRectsMatch(_pDstRc, _iDstAlloc, _pSrcRc, _iSrcAlloc, _pDstRect, _pSrcRect, FALSE)) { \
325 VBOXVDBG_LOOP_LAST(); \
326 } \
327 else \
328 { \
329 VBOXVDBG_DUMP_RECTS_FORCE(); \
330 vboxVDbgPrint(("vboxVDbgDoCheckRectsMatch failed! The " _pszOpName " will be re-done so it can be debugged\n")); \
331 vboxVDbgDoPrintLopLastCmd("Don't redo the" _pszOpName); \
332 Assert(0); \
333 } \
334 _opDump; \
335 ); \
336 } while (0)
337
338#define VBOXVDBG_DEV_CHECK_SHARED(_pDevice, _pIsShared) do { \
339 *(_pIsShared) = FALSE; \
340 for (UINT i = 0; i < (_pDevice)->cRTs; ++i) { \
341 PVBOXWDDMDISP_ALLOCATION pRtVar = (_pDevice)->apRTs[i]; \
342 if (pRtVar->pRc->RcDesc.fFlags.SharedResource) { *(_pIsShared) = TRUE; break; } \
343 } \
344 if (!*(_pIsShared)) { \
345 for (UINT i = 0, iSampler = 0; iSampler < (_pDevice)->cSamplerTextures; ++i) { \
346 Assert(i < RT_ELEMENTS((_pDevice)->aSamplerTextures)); \
347 if (!(_pDevice)->aSamplerTextures[i]) continue; \
348 ++iSampler; \
349 if (!(_pDevice)->aSamplerTextures[i]->RcDesc.fFlags.SharedResource) continue; \
350 *(_pIsShared) = TRUE; break; \
351 } \
352 } \
353 } while (0)
354
355#define VBOXVDBG_IS_DUMP_SHARED_ALLOWED_DEV(_pDevice, _pIsAllowed) do { \
356 VBOXVDBG_DEV_CHECK_SHARED(_pDevice, _pIsAllowed); \
357 if (*(_pIsAllowed)) \
358 { \
359 *(_pIsAllowed) = VBOXVDBG_IS_DUMP_ALLOWED(Shared); \
360 } \
361 } while (0)
362
363#define VBOXVDBG_IS_BREAK_SHARED_ALLOWED_DEV(_pDevice, _pIsAllowed) do { \
364 VBOXVDBG_DEV_CHECK_SHARED(_pDevice, _pIsAllowed); \
365 if (*(_pIsAllowed)) \
366 { \
367 *(_pIsAllowed) = VBOXVDBG_IS_BREAK_ALLOWED(Shared); \
368 } \
369 } while (0)
370
371#define VBOXVDBG_DUMP_DRAWPRIM_ENTER(_pDevice) do { \
372 BOOL fDumpShaded = FALSE; \
373 VBOXVDBG_IS_DUMP_SHARED_ALLOWED_DEV(_pDevice, &fDumpShaded); \
374 if (fDumpShaded \
375 || VBOXVDBG_IS_DUMP_ALLOWED(DrawPrim)) \
376 { \
377 vboxVDbgDoDumpRt("==>"__FUNCTION__": Rt: ", (_pDevice), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Flush) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim)); \
378 }\
379 } while (0)
380
381#define VBOXVDBG_DUMP_DRAWPRIM_LEAVE(_pDevice) do { \
382 BOOL fDumpShaded = FALSE; \
383 VBOXVDBG_IS_DUMP_SHARED_ALLOWED_DEV(_pDevice, &fDumpShaded); \
384 if (fDumpShaded \
385 || VBOXVDBG_IS_DUMP_ALLOWED(DrawPrim)) \
386 { \
387 vboxVDbgDoDumpRt("<=="__FUNCTION__": Rt: ", (_pDevice), "", \
388 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
389 }\
390 } while (0)
391
392#define VBOXVDBG_BREAK_SHARED_DEV(_pDevice) do { \
393 BOOL fBreakShaded = FALSE; \
394 VBOXVDBG_IS_BREAK_SHARED_ALLOWED_DEV(_pDevice, &fBreakShaded); \
395 if (fBreakShaded) { \
396 vboxVDbgPrint((__FUNCTION__"== Break on shared access\n")); \
397 AssertFailed(); \
398 } \
399 } while (0)
400
401#define VBOXVDBG_DUMP_SETTEXTURE(_pRc) do { \
402 if (VBOXVDBG_IS_DUMP_ALLOWED(SetTexture) \
403 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pRc) \
404 ) \
405 { \
406 vboxVDbgDoDumpRcRect("== "__FUNCTION__": ", &(_pRc)->aAllocations[0], NULL, NULL, "", \
407 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(SetTexture) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
408 } \
409 } while (0)
410
411#define VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { \
412 if (VBOXVDBG_IS_DUMP_ALLOWED(TexBlt) \
413 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pSrcRc) \
414 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pDstRc) \
415 ) \
416 { \
417 RECT SrcRect = *(_pSrcRect); \
418 RECT _DstRect; \
419 vboxWddmRectMoved(&_DstRect, &SrcRect, (_pDstPoint)->x, (_pDstPoint)->y); \
420 vboxVDbgDoDumpRcRect("==> "__FUNCTION__": Src: ", &(_pSrcRc)->aAllocations[0], NULL, &SrcRect, "", \
421 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(TexBlt) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
422 vboxVDbgDoDumpRcRect("==> "__FUNCTION__": Dst: ", &(_pDstRc)->aAllocations[0], NULL, &_DstRect, "", \
423 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(TexBlt) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
424 } \
425 } while (0)
426
427#define VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { \
428 if (VBOXVDBG_DUMP_RECTS_FORCED() \
429 || VBOXVDBG_IS_DUMP_ALLOWED(TexBlt) \
430 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pSrcRc) \
431 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pDstRc) \
432 ) \
433 { \
434 RECT SrcRect = *(_pSrcRect); \
435 RECT _DstRect; \
436 vboxWddmRectMoved(&_DstRect, &SrcRect, (_pDstPoint)->x, (_pDstPoint)->y); \
437 vboxVDbgDoDumpRcRect("<== "__FUNCTION__": Src: ", &(_pSrcRc)->aAllocations[0], NULL, &SrcRect, "", \
438 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(TexBlt) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
439 vboxVDbgDoDumpRcRect("<== "__FUNCTION__": Dst: ", &(_pDstRc)->aAllocations[0], NULL, &_DstRect, "", \
440 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(TexBlt) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
441 } \
442 } while (0)
443
444#define VBOXVDBG_DUMP_STRETCH_RECT(_type, _str, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { \
445 if (VBOXVDBG_IS_DUMP_ALLOWED(_type) \
446 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED((_pSrcAlloc)->pRc) \
447 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED((_pDstAlloc)->pRc) \
448 ) \
449 { \
450 DWORD fFlags = VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Blt) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared); \
451 if (VBOXVDBG_DUMP_TYPE_CONTENTS(fFlags) && \
452 ((_pSrcSurf) == (_pDstSurf) \
453 && ( ((_pSrcRect) && (_pDstRect) && !memcmp((_pSrcRect), (_pDstRect), sizeof (_pDstRect))) \
454 || ((_pSrcRect) == (_pDstRect)) \
455 )) ) \
456 { \
457 vboxVDbgPrint((_str #_type ": skipping content dump of the same rect for one surfcace\n")); \
458 fFlags = VBOXVDBG_DUMP_TYPE_GET_FLOW_ONLY(fFlags); \
459 } \
460 RECT Rect, *pRect; \
461 if (_pSrcRect) \
462 { \
463 Rect = *((RECT*)(_pSrcRect)); \
464 pRect = &Rect; \
465 } \
466 else \
467 pRect = NULL; \
468 vboxVDbgDoDumpRcRect(_str __FUNCTION__" Src: ", (_pSrcAlloc), (_pSrcSurf), pRect, "", \
469 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(_type) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
470 if (_pDstRect) \
471 { \
472 Rect = *((RECT*)(_pDstRect)); \
473 pRect = &Rect; \
474 } \
475 else \
476 pRect = NULL; \
477 vboxVDbgDoDumpRcRect(_str __FUNCTION__" Dst: ", (_pDstAlloc), (_pDstSurf), pRect, "", \
478 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(_type) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
479 } \
480 } while (0)
481
482#define VBOXVDBG_DUMP_BLT_ENTER(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
483 VBOXVDBG_DUMP_STRETCH_RECT(Blt, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
484
485#define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
486 VBOXVDBG_DUMP_STRETCH_RECT(Blt, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
487
488#define VBOXVDBG_DUMP_SWAPCHAIN_SYNC_ENTER(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
489 VBOXVDBG_DUMP_STRETCH_RECT(ScSync, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
490
491#define VBOXVDBG_DUMP_SWAPCHAIN_SYNC_LEAVE(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
492 VBOXVDBG_DUMP_STRETCH_RECT(ScSync, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
493
494#define VBOXVDBG_IS_SKIP_DWM_WND_UPDATE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) ( \
495 g_VBoxVDbgFSkipCheckTexBltDwmWndUpdate \
496 && ( \
497 VBOXVDBG_IS_DWM() \
498 && (_pSrcRc)->RcDesc.enmPool == D3DDDIPOOL_SYSTEMMEM \
499 && (_pSrcRc)->RcDesc.enmFormat == D3DDDIFMT_A8R8G8B8 \
500 && (_pSrcRc)->cAllocations == 1 \
501 && (_pDstRc)->RcDesc.enmPool == D3DDDIPOOL_VIDEOMEMORY \
502 && (_pDstRc)->RcDesc.enmFormat == D3DDDIFMT_A8R8G8B8 \
503 && (_pDstRc)->RcDesc.fFlags.RenderTarget \
504 && (_pDstRc)->RcDesc.fFlags.NotLockable \
505 && (_pDstRc)->cAllocations == 1 \
506 && (_pSrcRc)->aAllocations[0].SurfDesc.width == (_pDstRc)->aAllocations[0].SurfDesc.width \
507 && (_pSrcRc)->aAllocations[0].SurfDesc.height == (_pDstRc)->aAllocations[0].SurfDesc.height \
508 ) \
509 )
510
511#define VBOXVDBG_CHECK_TEXBLT(_opTexBlt, _pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { \
512 if (VBOXVDBG_IS_CHECK_ALLOWED(TexBlt)) { \
513 if (VBOXVDBG_IS_SKIP_DWM_WND_UPDATE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint)) \
514 { \
515 vboxVDbgPrint(("TEXBLT: skipping check for dwm wnd update\n")); \
516 } \
517 else \
518 { \
519 RECT DstRect; \
520 DstRect.left = (_pDstPoint)->x; \
521 DstRect.right = (_pDstPoint)->x + (_pSrcRect)->right - (_pSrcRect)->left; \
522 DstRect.top = (_pDstPoint)->y; \
523 DstRect.bottom = (_pDstPoint)->y + (_pSrcRect)->bottom - (_pSrcRect)->top; \
524 VBOXVDBG_CHECK_RECTS(\
525 VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint); \
526 _opTexBlt ,\
527 VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint), \
528 "TexBlt", \
529 _pDstRc, 0, _pSrcRc, 0, &DstRect, _pSrcRect); \
530 break; \
531 } \
532 } \
533 VBOXVDBG_DUMP_RECTS_INIT(0); \
534 VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint); \
535 _opTexBlt;\
536 VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint); \
537 } while (0)
538
539#define VBOXVDBG_CHECK_STRETCH_RECT(_type, _op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { \
540 if (VBOXVDBG_IS_CHECK_ALLOWED(_type)) { \
541 VBOXVDBG_CHECK_RECTS(\
542 VBOXVDBG_DUMP_STRETCH_RECT(_type, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect); \
543 _op ,\
544 VBOXVDBG_DUMP_STRETCH_RECT(_type, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect), \
545 #_type , \
546 _pDstAlloc->pRc, _pDstAlloc->iAlloc, _pSrcAlloc->pRc, _pSrcAlloc->iAlloc, _pDstRect, _pSrcRect); \
547 } \
548 else \
549 { \
550 VBOXVDBG_DUMP_RECTS_INIT(0); \
551 VBOXVDBG_DUMP_STRETCH_RECT(_type, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect); \
552 _op;\
553 VBOXVDBG_DUMP_STRETCH_RECT(_type, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect); \
554 } \
555 } while (0)
556
557#define VBOXVDBG_CHECK_BLT(_opBlt, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
558 VBOXVDBG_CHECK_STRETCH_RECT(Blt, _opBlt, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
559
560#define VBOXVDBG_CHECK_SWAPCHAIN_SYNC(_op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
561 VBOXVDBG_CHECK_STRETCH_RECT(ScSync, _op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
562
563#define VBOXVDBG_DUMP_SYNC_RT(_pBbSurf) do { \
564 if (VBOXVDBG_IS_DUMP_ALLOWED(RtSynch)) \
565 { \
566 vboxVDbgDoDumpRcRect("== "__FUNCTION__" Bb:\n", NULL, (_pBbSurf), NULL, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(RtSynch)); \
567 } \
568 } while (0)
569
570#define VBOXVDBG_DUMP_PRESENT_ENTER(_pDevice, _pSwapchain) do { \
571 if (VBOXVDBG_IS_DUMP_ALLOWED(PresentEnter)) { \
572 if (!(_pSwapchain)->fFlags.bRtReportingPresent) { \
573 vboxVDbgDoDumpBb("==>"__FUNCTION__" Bb:\n", (_pSwapchain)->pSwapChainIf, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(PresentEnter)); \
574 } \
575 else { \
576 PVBOXWDDMDISP_ALLOCATION pCurBb = vboxWddmSwapchainGetBb((_pSwapchain))->pAlloc; \
577 IDirect3DSurface9 *pSurf; \
578 HRESULT hr = vboxWddmSwapchainSurfGet(_pDevice, _pSwapchain, pCurBb, &pSurf); \
579 Assert(hr == S_OK); \
580 vboxVDbgDoDumpRcRect("== "__FUNCTION__" Bb:\n", pCurBb, pSurf, NULL, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(PresentEnter)); \
581 pSurf->Release(); \
582 } \
583 } \
584 } while (0)
585
586#define VBOXVDBG_DUMP_PRESENT_LEAVE(_pDevice, _pSwapchain) do { \
587 if (VBOXVDBG_IS_DUMP_ALLOWED(PresentLeave)) { \
588 if (!(_pSwapchain)->fFlags.bRtReportingPresent) { \
589 vboxVDbgDoDumpFb("<=="__FUNCTION__" Fb:\n", (_pSwapchain)->pSwapChainIf, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(PresentLeave)); \
590 } \
591 else { \
592 vboxVDbgPrint(("PRESENT_LEAVE: unsupported for Rt Reporting mode\n")); \
593 } \
594 } \
595 } while (0)
596
597
598#define VBOXVDBG_DUMP_FLUSH(_pDevice) do { \
599 if (VBOXVDBG_IS_DUMP_ALLOWED(Flush)) \
600 { \
601 vboxVDbgDoDumpRt("== "__FUNCTION__": Rt: ", (_pDevice), "", \
602 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Flush)); \
603 }\
604 } while (0)
605
606#define VBOXVDBG_DUMP_LOCK_ST(_pData) do { \
607 if (VBOXVDBG_IS_DUMP_ALLOWED(Lock) \
608 || VBOXVDBG_IS_DUMP_ALLOWED(Unlock) \
609 ) \
610 { \
611 vboxVDbgDoDumpLockSurfTex("== "__FUNCTION__": ", (_pData), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Lock)); \
612 } \
613 } while (0)
614
615#define VBOXVDBG_DUMP_UNLOCK_ST(_pData) do { \
616 if (VBOXVDBG_IS_DUMP_ALLOWED(Unlock) \
617 ) \
618 { \
619 vboxVDbgDoDumpUnlockSurfTex("== "__FUNCTION__": ", (_pData), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Unlock)); \
620 } \
621 } while (0)
622
623
624#define VBOXVDBG_CREATE_CHECK_SWAPCHAIN() do { \
625 if (g_VBoxVDbgCfgCreateSwapchainOnDdiOnce && g_VBoxVDbgInternalRc) { \
626 PVBOXWDDMDISP_SWAPCHAIN pSwapchain; \
627 HRESULT hr = vboxWddmSwapchainCreateIfForRc(g_VBoxVDbgInternalDevice, g_VBoxVDbgInternalRc, &pSwapchain); \
628 Assert(hr == S_OK); \
629 g_VBoxVDbgInternalRc = NULL; \
630 g_VBoxVDbgCfgCreateSwapchainOnDdiOnce = 0; \
631 } \
632 } while (0)
633
634#else
635#define VBOXVDBG_DUMP_DRAWPRIM_ENTER(_pDevice) do { } while (0)
636#define VBOXVDBG_DUMP_DRAWPRIM_LEAVE(_pDevice) do { } while (0)
637#define VBOXVDBG_DUMP_SETTEXTURE(_pRc) do { } while (0)
638#define VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { } while (0)
639#define VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { } while (0)
640#define VBOXVDBG_DUMP_BLT_ENTER(_pSrcRc, _pSrcSurf, _pSrcRect, _pDstRc, _pDstSurf, _pDstRect) do { } while (0)
641#define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcRc, _pSrcSurf, _pSrcRect, _pDstRc, _pDstSurf, _pDstRect) do { } while (0)
642#define VBOXVDBG_DUMP_SYNC_RT(_pBbSurf) do { } while (0)
643#define VBOXVDBG_DUMP_FLUSH(_pDevice) do { } while (0)
644#define VBOXVDBG_DUMP_LOCK_ST(_pData) do { } while (0)
645#define VBOXVDBG_DUMP_UNLOCK_ST(_pData) do { } while (0)
646#define VBOXVDBG_DUMP_PRESENT_ENTER(_pDevice, _pSwapchain) do { } while (0)
647#define VBOXVDBG_DUMP_PRESENT_LEAVE(_pDevice, _pSwapchain) do { } while (0)
648#define VBOXVDBG_BREAK_SHARED(_pRc) do { } while (0)
649#define VBOXVDBG_BREAK_SHARED_DEV(_pDevice) do { } while (0)
650#define VBOXVDBG_BREAK_DDI() do { } while (0)
651#define VBOXVDBG_CHECK_SMSYNC(_pRc) do { } while (0)
652#define VBOXVDBG_CHECK_BLT(_opBlt, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { _opBlt; } while (0)
653#define VBOXVDBG_CHECK_TEXBLT(_opTexBlt, _pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { _opTexBlt; } while (0)
654#define VBOXVDBG_ASSERT_IS_DWM(_bDwm) do { } while (0)
655#define VBOXVDBG_CHECK_SWAPCHAIN_SYNC(_op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { _op; } while (0)
656#define VBOXVDBG_CREATE_CHECK_SWAPCHAIN() do { } while (0)
657#endif
658
659
660#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