VirtualBox

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

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

wddm/3d: burn fixes + logging enhancements

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