VirtualBox

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

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

wddm/3d: a bit more logging

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 28.8 KB
Line 
1/* $Id: VBoxDispDbg.h 41481 2012-05-29 14:26:46Z 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#define VBOXVDBG_DUMP_TYPEF_FLOW 0x00000001
212#define VBOXVDBG_DUMP_TYPEF_CONTENTS 0x00000002
213#define VBOXVDBG_DUMP_TYPEF_DONT_BREAK_ON_CONTENTS 0x00000004
214#define VBOXVDBG_DUMP_TYPEF_BREAK_ON_FLOW 0x00000008
215#define VBOXVDBG_DUMP_TYPEF_SHARED_ONLY 0x00000010
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_ENABLED_FOR_INFO(_pInfo, _fFlags) ( \
225 VBOXVDBG_DUMP_TYPE_ENABLED(_fFlags) \
226 && ( \
227 VBOXVDBG_DUMP_FLAGS_IS_CLEARED(_fFlags, VBOXVDBG_DUMP_TYPEF_SHARED_ONLY) \
228 || ((_pInfo)->pAlloc && (_pInfo)->pAlloc->pRc->aAllocations[0].hSharedHandle) \
229 ))
230
231#define VBOXVDBG_DUMP_TYPE_FLOW_ONLY(_fFlags) (VBOXVDBG_DUMP_FLAGS_IS_SET(_fFlags, VBOXVDBG_DUMP_TYPEF_FLOW) \
232 && VBOXVDBG_DUMP_FLAGS_IS_CLEARED(_fFlags, VBOXVDBG_DUMP_TYPEF_CONTENTS))
233#define VBOXVDBG_DUMP_TYPE_CONTENTS(_fFlags) (VBOXVDBG_DUMP_FLAGS_IS_SET(_fFlags, VBOXVDBG_DUMP_TYPEF_CONTENTS))
234#define VBOXVDBG_DUMP_TYPE_GET_FLOW_ONLY(_fFlags) ( \
235 VBOXVDBG_DUMP_FLAGS_SET( \
236 VBOXVDBG_DUMP_FLAGS_CLEAR(_fFlags, VBOXVDBG_DUMP_TYPEF_CONTENTS), \
237 VBOXVDBG_DUMP_TYPEF_FLOW) \
238 )
239
240VOID vboxVDbgDoDumpAllocRect(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, RECT *pRect, const char* pSuffix, DWORD fFlags);
241VOID vboxVDbgDoDumpRcRect(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DResource9 *pD3DRc, RECT *pRect, const char * pSuffix, DWORD fFlags);
242VOID vboxVDbgDoDumpLockUnlockSurfTex(const char * pPrefix, const PVBOXWDDMDISP_ALLOCATION pAlloc, const char * pSuffix, DWORD fFlags);
243VOID vboxVDbgDoDumpRt(const char * pPrefix, struct VBOXWDDMDISP_DEVICE *pDevice, const char * pSuffix, DWORD fFlags);
244VOID vboxVDbgDoDumpBb(const char * pPrefix, IDirect3DSwapChain9 *pSwapchainIf, const char * pSuffix, DWORD fFlags);
245VOID vboxVDbgDoDumpFb(const char * pPrefix, IDirect3DSwapChain9 *pSwapchainIf, const char * pSuffix, DWORD fFlags);
246VOID vboxVDbgDoDumpSamplers(const char * pPrefix, struct VBOXWDDMDISP_DEVICE *pDevice, const char * pSuffix, DWORD fFlags);
247
248void vboxVDbgDoPrintRect(const char * pPrefix, const RECT *pRect, const char * pSuffix);
249void vboxVDbgDoPrintAlloc(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const char * pSuffix);
250
251VOID vboxVDbgDoDumpLockSurfTex(const char * pPrefix, const D3DDDIARG_LOCK* pData, const char * pSuffix, DWORD fFlags);
252VOID vboxVDbgDoDumpUnlockSurfTex(const char * pPrefix, const D3DDDIARG_UNLOCK* pData, const char * pSuffix, DWORD fFlags);
253
254BOOL vboxVDbgDoCheckRectsMatch(const PVBOXWDDMDISP_RESOURCE pDstRc, uint32_t iDstAlloc,
255 const PVBOXWDDMDISP_RESOURCE pSrcRc, uint32_t iSrcAlloc,
256 const RECT *pDstRect,
257 const RECT *pSrcRect,
258 BOOL fBreakOnMismatch);
259
260BOOL vboxVDbgDoCheckExe(const char * pszName);
261
262VOID vboxVDbgDoPrintLopLastCmd(const char* pszDesc);
263
264extern DWORD g_VBoxVDbgPid;
265#define VBOXVDBG_IS_PID(_pid) ((_pid) == (g_VBoxVDbgPid ? g_VBoxVDbgPid : (g_VBoxVDbgPid = GetCurrentProcessId())))
266#define VBOXVDBG_IS_DUMP_ALLOWED_PID(_pid) (((int)(_pid)) > 0 ? VBOXVDBG_IS_PID(_pid) : !VBOXVDBG_IS_PID(-((int)(_pid))))
267
268#define VBOXVDBG_CHECK_EXE(_pszName) (vboxVDbgDoCheckExe(_pszName))
269#define VBOXVDBG_IS_DWM() (!!(g_VBoxVDbgFIsDwm >=0 ? g_VBoxVDbgFIsDwm : (g_VBoxVDbgFIsDwm = VBOXVDBG_CHECK_EXE("dwm.exe"))))
270
271#define VBOXVDBG_ASSERT_IS_DWM(_bDwm) do { \
272 Assert((!VBOXVDBG_IS_DWM()) == (!(_bDwm))); \
273 } while (0)
274
275#define VBOXVDBG_DUMP_FLAGS_FOR_TYPE(_type) g_VBoxVDbgFDump##_type
276#define VBOXVDBG_BREAK_FLAGS_FOR_TYPE(_type) g_VBoxVDbgFBreak##_type
277#define VBOXVDBG_CHECK_FLAGS_FOR_TYPE(_type) g_VBoxVDbgFCheck##_type
278#define VBOXVDBG_IS_DUMP_ALLOWED(_type) ( VBOXVDBG_DUMP_TYPE_ENABLED(VBOXVDBG_DUMP_FLAGS_FOR_TYPE(_type)) )
279
280#define VBOXVDBG_IS_BREAK_ALLOWED(_type) ( !!VBOXVDBG_BREAK_FLAGS_FOR_TYPE(_type) )
281
282#define VBOXVDBG_IS_CHECK_ALLOWED(_type) ( !!VBOXVDBG_CHECK_FLAGS_FOR_TYPE(_type) )
283
284#define VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pRc) (\
285 (_pRc)->RcDesc.fFlags.SharedResource \
286 && VBOXVDBG_IS_DUMP_ALLOWED(Shared) \
287 )
288
289#define VBOXVDBG_IS_BREAK_SHARED_ALLOWED(_pRc) (\
290 (_pRc)->RcDesc.fFlags.SharedResource \
291 && VBOXVDBG_IS_BREAK_ALLOWED(Shared) \
292 )
293
294#define VBOXVDBG_BREAK_SHARED(_pRc) do { \
295 if (VBOXVDBG_IS_BREAK_SHARED_ALLOWED(_pRc)) { \
296 vboxVDbgPrint(("Break on shared access: Rc(0x%p), SharedHandle(0x%p)\n", (_pRc), (_pRc)->aAllocations[0].hSharedHandle)); \
297 AssertFailed(); \
298 } \
299 } while (0)
300
301#define VBOXVDBG_BREAK_DDI() do { \
302 if (VBOXVDBG_IS_BREAK_ALLOWED(Ddi)) { \
303 AssertFailed(); \
304 } \
305 } while (0)
306
307#define VBOXVDBG_LOOP_LAST() do { vboxVDbgLoop = 0; } while (0)
308
309#define VBOXVDBG_LOOP(_op) do { \
310 DWORD vboxVDbgLoop = 1; \
311 do { \
312 _op; \
313 } while (vboxVDbgLoop); \
314 } while (0)
315
316#define VBOXVDBG_CHECK_SMSYNC(_pRc) do { \
317 if (VBOXVDBG_IS_CHECK_ALLOWED(SysMemSync)) { \
318 vboxWddmDbgRcSynchMemCheck((_pRc)); \
319 } \
320 } while (0)
321
322#define VBOXVDBG_DUMP_RECTS_INIT(_d) DWORD vboxVDbgDumpRects = _d;
323#define VBOXVDBG_DUMP_RECTS_FORCE() vboxVDbgDumpRects = 1;
324#define VBOXVDBG_DUMP_RECTS_FORCED() (!!vboxVDbgDumpRects)
325
326#define VBOXVDBG_CHECK_RECTS(_opRests, _opDump, _pszOpName, _pDstRc, _iDstAlloc, _pSrcRc, _iSrcAlloc, _pDstRect, _pSrcRect) do { \
327 VBOXVDBG_LOOP(\
328 VBOXVDBG_DUMP_RECTS_INIT(0); \
329 _opRests; \
330 if (vboxVDbgDoCheckRectsMatch(_pDstRc, _iDstAlloc, _pSrcRc, _iSrcAlloc, _pDstRect, _pSrcRect, FALSE)) { \
331 VBOXVDBG_LOOP_LAST(); \
332 } \
333 else \
334 { \
335 VBOXVDBG_DUMP_RECTS_FORCE(); \
336 vboxVDbgPrint(("vboxVDbgDoCheckRectsMatch failed! The " _pszOpName " will be re-done so it can be debugged\n")); \
337 vboxVDbgDoPrintLopLastCmd("Don't redo the" _pszOpName); \
338 Assert(0); \
339 } \
340 _opDump; \
341 ); \
342 } while (0)
343
344#define VBOXVDBG_DEV_CHECK_SHARED(_pDevice, _pIsShared) do { \
345 *(_pIsShared) = FALSE; \
346 for (UINT i = 0; i < (_pDevice)->cRTs; ++i) { \
347 PVBOXWDDMDISP_ALLOCATION pRtVar = (_pDevice)->apRTs[i]; \
348 if (pRtVar->pRc->RcDesc.fFlags.SharedResource) { *(_pIsShared) = TRUE; break; } \
349 } \
350 if (!*(_pIsShared)) { \
351 for (UINT i = 0, iSampler = 0; iSampler < (_pDevice)->cSamplerTextures; ++i) { \
352 Assert(i < RT_ELEMENTS((_pDevice)->aSamplerTextures)); \
353 if (!(_pDevice)->aSamplerTextures[i]) continue; \
354 ++iSampler; \
355 if (!(_pDevice)->aSamplerTextures[i]->RcDesc.fFlags.SharedResource) continue; \
356 *(_pIsShared) = TRUE; break; \
357 } \
358 } \
359 } while (0)
360
361#define VBOXVDBG_IS_DUMP_SHARED_ALLOWED_DEV(_pDevice, _pIsAllowed) do { \
362 VBOXVDBG_DEV_CHECK_SHARED(_pDevice, _pIsAllowed); \
363 if (*(_pIsAllowed)) \
364 { \
365 *(_pIsAllowed) = VBOXVDBG_IS_DUMP_ALLOWED(Shared); \
366 } \
367 } while (0)
368
369#define VBOXVDBG_IS_BREAK_SHARED_ALLOWED_DEV(_pDevice, _pIsAllowed) do { \
370 VBOXVDBG_DEV_CHECK_SHARED(_pDevice, _pIsAllowed); \
371 if (*(_pIsAllowed)) \
372 { \
373 *(_pIsAllowed) = VBOXVDBG_IS_BREAK_ALLOWED(Shared); \
374 } \
375 } while (0)
376
377#define VBOXVDBG_DUMP_DRAWPRIM_ENTER(_pDevice) do { \
378 BOOL fDumpShaded = FALSE; \
379 VBOXVDBG_IS_DUMP_SHARED_ALLOWED_DEV(_pDevice, &fDumpShaded); \
380 if (fDumpShaded \
381 || VBOXVDBG_IS_DUMP_ALLOWED(DrawPrim)) \
382 { \
383 vboxVDbgDoDumpRt("==>"__FUNCTION__": Rt: ", (_pDevice), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim)); \
384 vboxVDbgDoDumpSamplers("==>"__FUNCTION__": Sl: ", (_pDevice), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim)); \
385 }\
386 } while (0)
387
388#define VBOXVDBG_DUMP_DRAWPRIM_LEAVE(_pDevice) do { \
389 BOOL fDumpShaded = FALSE; \
390 VBOXVDBG_IS_DUMP_SHARED_ALLOWED_DEV(_pDevice, &fDumpShaded); \
391 if (fDumpShaded \
392 || VBOXVDBG_IS_DUMP_ALLOWED(DrawPrim)) \
393 { \
394 vboxVDbgDoDumpRt("<=="__FUNCTION__": Rt: ", (_pDevice), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim)); \
395 vboxVDbgDoDumpSamplers("<=="__FUNCTION__": Sl: ", (_pDevice), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim)); \
396 }\
397 } while (0)
398
399#define VBOXVDBG_BREAK_SHARED_DEV(_pDevice) do { \
400 BOOL fBreakShaded = FALSE; \
401 VBOXVDBG_IS_BREAK_SHARED_ALLOWED_DEV(_pDevice, &fBreakShaded); \
402 if (fBreakShaded) { \
403 vboxVDbgPrint((__FUNCTION__"== Break on shared access\n")); \
404 AssertFailed(); \
405 } \
406 } while (0)
407
408#define VBOXVDBG_DUMP_SETTEXTURE(_pRc) do { \
409 if (VBOXVDBG_IS_DUMP_ALLOWED(SetTexture) \
410 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pRc) \
411 ) \
412 { \
413 vboxVDbgDoDumpRcRect("== "__FUNCTION__": ", &(_pRc)->aAllocations[0], NULL, NULL, "", \
414 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(SetTexture) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
415 } \
416 } while (0)
417
418#define VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { \
419 if (VBOXVDBG_IS_DUMP_ALLOWED(TexBlt) \
420 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pSrcRc) \
421 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pDstRc) \
422 ) \
423 { \
424 RECT SrcRect = *(_pSrcRect); \
425 RECT _DstRect; \
426 vboxWddmRectMoved(&_DstRect, &SrcRect, (_pDstPoint)->x, (_pDstPoint)->y); \
427 vboxVDbgDoDumpRcRect("==> "__FUNCTION__": Src: ", &(_pSrcRc)->aAllocations[0], NULL, &SrcRect, "", \
428 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(TexBlt) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
429 vboxVDbgDoDumpRcRect("==> "__FUNCTION__": Dst: ", &(_pDstRc)->aAllocations[0], NULL, &_DstRect, "", \
430 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(TexBlt) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
431 } \
432 } while (0)
433
434#define VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { \
435 if (VBOXVDBG_DUMP_RECTS_FORCED() \
436 || VBOXVDBG_IS_DUMP_ALLOWED(TexBlt) \
437 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pSrcRc) \
438 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pDstRc) \
439 ) \
440 { \
441 RECT SrcRect = *(_pSrcRect); \
442 RECT _DstRect; \
443 vboxWddmRectMoved(&_DstRect, &SrcRect, (_pDstPoint)->x, (_pDstPoint)->y); \
444 vboxVDbgDoDumpRcRect("<== "__FUNCTION__": Src: ", &(_pSrcRc)->aAllocations[0], NULL, &SrcRect, "", \
445 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(TexBlt) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
446 vboxVDbgDoDumpRcRect("<== "__FUNCTION__": Dst: ", &(_pDstRc)->aAllocations[0], NULL, &_DstRect, "", \
447 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(TexBlt) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
448 } \
449 } while (0)
450
451#define VBOXVDBG_DUMP_STRETCH_RECT(_type, _str, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { \
452 if (VBOXVDBG_IS_DUMP_ALLOWED(_type) \
453 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED((_pSrcAlloc)->pRc) \
454 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED((_pDstAlloc)->pRc) \
455 ) \
456 { \
457 DWORD fFlags = VBOXVDBG_DUMP_FLAGS_FOR_TYPE(_type) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared); \
458 if (VBOXVDBG_DUMP_TYPE_CONTENTS(fFlags) && \
459 ((_pSrcSurf) == (_pDstSurf) \
460 && ( ((_pSrcRect) && (_pDstRect) && !memcmp((_pSrcRect), (_pDstRect), sizeof (_pDstRect))) \
461 || ((_pSrcRect) == (_pDstRect)) \
462 )) ) \
463 { \
464 vboxVDbgPrint((_str #_type ": skipping content dump of the same rect for one surfcace\n")); \
465 fFlags = VBOXVDBG_DUMP_TYPE_GET_FLOW_ONLY(fFlags); \
466 } \
467 RECT Rect, *pRect; \
468 if (_pSrcRect) \
469 { \
470 Rect = *((RECT*)(_pSrcRect)); \
471 pRect = &Rect; \
472 } \
473 else \
474 pRect = NULL; \
475 vboxVDbgDoDumpRcRect(_str __FUNCTION__" Src: ", (_pSrcAlloc), (_pSrcSurf), pRect, "", fFlags); \
476 if (_pDstRect) \
477 { \
478 Rect = *((RECT*)(_pDstRect)); \
479 pRect = &Rect; \
480 } \
481 else \
482 pRect = NULL; \
483 vboxVDbgDoDumpRcRect(_str __FUNCTION__" Dst: ", (_pDstAlloc), (_pDstSurf), pRect, "", fFlags); \
484 } \
485 } while (0)
486
487#define VBOXVDBG_DUMP_BLT_ENTER(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
488 VBOXVDBG_DUMP_STRETCH_RECT(Blt, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
489
490#define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
491 VBOXVDBG_DUMP_STRETCH_RECT(Blt, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
492
493#define VBOXVDBG_DUMP_SWAPCHAIN_SYNC_ENTER(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
494 VBOXVDBG_DUMP_STRETCH_RECT(ScSync, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
495
496#define VBOXVDBG_DUMP_SWAPCHAIN_SYNC_LEAVE(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
497 VBOXVDBG_DUMP_STRETCH_RECT(ScSync, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
498
499#define VBOXVDBG_IS_SKIP_DWM_WND_UPDATE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) ( \
500 g_VBoxVDbgFSkipCheckTexBltDwmWndUpdate \
501 && ( \
502 VBOXVDBG_IS_DWM() \
503 && (_pSrcRc)->RcDesc.enmPool == D3DDDIPOOL_SYSTEMMEM \
504 && (_pSrcRc)->RcDesc.enmFormat == D3DDDIFMT_A8R8G8B8 \
505 && (_pSrcRc)->cAllocations == 1 \
506 && (_pDstRc)->RcDesc.enmPool == D3DDDIPOOL_VIDEOMEMORY \
507 && (_pDstRc)->RcDesc.enmFormat == D3DDDIFMT_A8R8G8B8 \
508 && (_pDstRc)->RcDesc.fFlags.RenderTarget \
509 && (_pDstRc)->RcDesc.fFlags.NotLockable \
510 && (_pDstRc)->cAllocations == 1 \
511 && (_pSrcRc)->aAllocations[0].SurfDesc.width == (_pDstRc)->aAllocations[0].SurfDesc.width \
512 && (_pSrcRc)->aAllocations[0].SurfDesc.height == (_pDstRc)->aAllocations[0].SurfDesc.height \
513 ) \
514 )
515
516#define VBOXVDBG_CHECK_TEXBLT(_opTexBlt, _pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { \
517 if (VBOXVDBG_IS_CHECK_ALLOWED(TexBlt)) { \
518 if (VBOXVDBG_IS_SKIP_DWM_WND_UPDATE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint)) \
519 { \
520 vboxVDbgPrint(("TEXBLT: skipping check for dwm wnd update\n")); \
521 } \
522 else \
523 { \
524 RECT DstRect; \
525 DstRect.left = (_pDstPoint)->x; \
526 DstRect.right = (_pDstPoint)->x + (_pSrcRect)->right - (_pSrcRect)->left; \
527 DstRect.top = (_pDstPoint)->y; \
528 DstRect.bottom = (_pDstPoint)->y + (_pSrcRect)->bottom - (_pSrcRect)->top; \
529 VBOXVDBG_CHECK_RECTS(\
530 VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint); \
531 _opTexBlt ,\
532 VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint), \
533 "TexBlt", \
534 _pDstRc, 0, _pSrcRc, 0, &DstRect, _pSrcRect); \
535 break; \
536 } \
537 } \
538 VBOXVDBG_DUMP_RECTS_INIT(0); \
539 VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint); \
540 _opTexBlt;\
541 VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint); \
542 } while (0)
543
544#define VBOXVDBG_CHECK_STRETCH_RECT(_type, _op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { \
545 if (VBOXVDBG_IS_CHECK_ALLOWED(_type)) { \
546 VBOXVDBG_CHECK_RECTS(\
547 VBOXVDBG_DUMP_STRETCH_RECT(_type, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect); \
548 _op ,\
549 VBOXVDBG_DUMP_STRETCH_RECT(_type, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect), \
550 #_type , \
551 _pDstAlloc->pRc, _pDstAlloc->iAlloc, _pSrcAlloc->pRc, _pSrcAlloc->iAlloc, _pDstRect, _pSrcRect); \
552 } \
553 else \
554 { \
555 VBOXVDBG_DUMP_RECTS_INIT(0); \
556 VBOXVDBG_DUMP_STRETCH_RECT(_type, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect); \
557 _op;\
558 VBOXVDBG_DUMP_STRETCH_RECT(_type, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect); \
559 } \
560 } while (0)
561
562#define VBOXVDBG_CHECK_BLT(_opBlt, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
563 VBOXVDBG_CHECK_STRETCH_RECT(Blt, _opBlt, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
564
565#define VBOXVDBG_CHECK_SWAPCHAIN_SYNC(_op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
566 VBOXVDBG_CHECK_STRETCH_RECT(ScSync, _op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
567
568#define VBOXVDBG_DUMP_SYNC_RT(_pBbSurf) do { \
569 if (VBOXVDBG_IS_DUMP_ALLOWED(RtSynch)) \
570 { \
571 vboxVDbgDoDumpRcRect("== "__FUNCTION__" Bb:\n", NULL, (_pBbSurf), NULL, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(RtSynch)); \
572 } \
573 } while (0)
574
575#define VBOXVDBG_DUMP_PRESENT_ENTER(_pDevice, _pSwapchain) do { \
576 if (VBOXVDBG_IS_DUMP_ALLOWED(PresentEnter)) { \
577 if (!(_pSwapchain)->fFlags.bRtReportingPresent) { \
578 vboxVDbgDoDumpBb("==>"__FUNCTION__" Bb:\n", (_pSwapchain)->pSwapChainIf, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(PresentEnter)); \
579 } \
580 else { \
581 PVBOXWDDMDISP_ALLOCATION pCurBb = vboxWddmSwapchainGetBb((_pSwapchain))->pAlloc; \
582 IDirect3DSurface9 *pSurf; \
583 HRESULT hr = vboxWddmSwapchainSurfGet(_pDevice, _pSwapchain, pCurBb, &pSurf); \
584 Assert(hr == S_OK); \
585 vboxVDbgDoDumpRcRect("== "__FUNCTION__" Bb:\n", pCurBb, pSurf, NULL, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(PresentEnter)); \
586 pSurf->Release(); \
587 } \
588 } \
589 } while (0)
590
591#define VBOXVDBG_DUMP_PRESENT_LEAVE(_pDevice, _pSwapchain) do { \
592 if (VBOXVDBG_IS_DUMP_ALLOWED(PresentLeave)) { \
593 if (!(_pSwapchain)->fFlags.bRtReportingPresent) { \
594 vboxVDbgDoDumpFb("<=="__FUNCTION__" Fb:\n", (_pSwapchain)->pSwapChainIf, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(PresentLeave)); \
595 } \
596 else { \
597 vboxVDbgPrint(("PRESENT_LEAVE: unsupported for Rt Reporting mode\n")); \
598 } \
599 } \
600 } while (0)
601
602
603#define VBOXVDBG_DUMP_FLUSH(_pDevice) do { \
604 if (VBOXVDBG_IS_DUMP_ALLOWED(Flush)) \
605 { \
606 vboxVDbgDoDumpRt("== "__FUNCTION__": Rt: ", (_pDevice), "", \
607 VBOXVDBG_DUMP_FLAGS_CLEAR(VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Flush), VBOXVDBG_DUMP_TYPEF_SHARED_ONLY)); \
608 }\
609 } while (0)
610
611#define VBOXVDBG_DUMP_LOCK_ST(_pData) do { \
612 if (VBOXVDBG_IS_DUMP_ALLOWED(Lock) \
613 || VBOXVDBG_IS_DUMP_ALLOWED(Unlock) \
614 ) \
615 { \
616 vboxVDbgDoDumpLockSurfTex("== "__FUNCTION__": ", (_pData), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Lock)); \
617 } \
618 } while (0)
619
620#define VBOXVDBG_DUMP_UNLOCK_ST(_pData) do { \
621 if (VBOXVDBG_IS_DUMP_ALLOWED(Unlock) \
622 ) \
623 { \
624 vboxVDbgDoDumpUnlockSurfTex("== "__FUNCTION__": ", (_pData), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Unlock)); \
625 } \
626 } while (0)
627
628
629#define VBOXVDBG_CREATE_CHECK_SWAPCHAIN() do { \
630 if (g_VBoxVDbgCfgCreateSwapchainOnDdiOnce && g_VBoxVDbgInternalRc) { \
631 PVBOXWDDMDISP_SWAPCHAIN pSwapchain; \
632 HRESULT hr = vboxWddmSwapchainCreateIfForRc(g_VBoxVDbgInternalDevice, g_VBoxVDbgInternalRc, &pSwapchain); \
633 Assert(hr == S_OK); \
634 g_VBoxVDbgInternalRc = NULL; \
635 g_VBoxVDbgCfgCreateSwapchainOnDdiOnce = 0; \
636 } \
637 } while (0)
638
639#else
640#define VBOXVDBG_DUMP_DRAWPRIM_ENTER(_pDevice) do { } while (0)
641#define VBOXVDBG_DUMP_DRAWPRIM_LEAVE(_pDevice) do { } while (0)
642#define VBOXVDBG_DUMP_SETTEXTURE(_pRc) do { } while (0)
643#define VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { } while (0)
644#define VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { } while (0)
645#define VBOXVDBG_DUMP_BLT_ENTER(_pSrcRc, _pSrcSurf, _pSrcRect, _pDstRc, _pDstSurf, _pDstRect) do { } while (0)
646#define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcRc, _pSrcSurf, _pSrcRect, _pDstRc, _pDstSurf, _pDstRect) do { } while (0)
647#define VBOXVDBG_DUMP_SYNC_RT(_pBbSurf) do { } while (0)
648#define VBOXVDBG_DUMP_FLUSH(_pDevice) do { } while (0)
649#define VBOXVDBG_DUMP_LOCK_ST(_pData) do { } while (0)
650#define VBOXVDBG_DUMP_UNLOCK_ST(_pData) do { } while (0)
651#define VBOXVDBG_DUMP_PRESENT_ENTER(_pDevice, _pSwapchain) do { } while (0)
652#define VBOXVDBG_DUMP_PRESENT_LEAVE(_pDevice, _pSwapchain) do { } while (0)
653#define VBOXVDBG_BREAK_SHARED(_pRc) do { } while (0)
654#define VBOXVDBG_BREAK_SHARED_DEV(_pDevice) do { } while (0)
655#define VBOXVDBG_BREAK_DDI() do { } while (0)
656#define VBOXVDBG_CHECK_SMSYNC(_pRc) do { } while (0)
657#define VBOXVDBG_CHECK_BLT(_opBlt, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { _opBlt; } while (0)
658#define VBOXVDBG_CHECK_TEXBLT(_opTexBlt, _pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { _opTexBlt; } while (0)
659#define VBOXVDBG_ASSERT_IS_DWM(_bDwm) do { } while (0)
660#define VBOXVDBG_CHECK_SWAPCHAIN_SYNC(_op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { _op; } while (0)
661#define VBOXVDBG_CREATE_CHECK_SWAPCHAIN() do { } while (0)
662#endif
663
664
665#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