VirtualBox

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

Last change on this file since 63105 was 63105, checked in by vboxsync, 8 years ago

GA/NT: warnings

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 29.0 KB
Line 
1/* $Id: VBoxDispDbg.h 63105 2016-08-06 16:20:00Z vboxsync $ */
2
3/** @file
4 * VBoxVideo Display D3D User mode dll
5 */
6
7/*
8 * Copyright (C) 2011-2016 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
47//# define VBOXWDDMDISP_DEBUG_PRINT_SHARED_CREATE
48
49//# define VBOXWDDMDISP_DEBUG_TIMER
50# endif
51
52# ifndef IN_VBOXCRHGSMI
53/* debug config vars */
54extern DWORD g_VBoxVDbgFDumpSetTexture;
55extern DWORD g_VBoxVDbgFDumpDrawPrim;
56extern DWORD g_VBoxVDbgFDumpTexBlt;
57extern DWORD g_VBoxVDbgFDumpBlt;
58extern DWORD g_VBoxVDbgFDumpRtSynch;
59extern DWORD g_VBoxVDbgFDumpFlush;
60extern DWORD g_VBoxVDbgFDumpShared;
61extern DWORD g_VBoxVDbgFDumpLock;
62extern DWORD g_VBoxVDbgFDumpUnlock;
63extern DWORD g_VBoxVDbgFDumpPresentEnter;
64extern DWORD g_VBoxVDbgFDumpPresentLeave;
65extern DWORD g_VBoxVDbgFDumpScSync;
66
67extern DWORD g_VBoxVDbgFBreakShared;
68extern DWORD g_VBoxVDbgFBreakDdi;
69
70extern DWORD g_VBoxVDbgFCheckSysMemSync;
71extern DWORD g_VBoxVDbgFCheckBlt;
72extern DWORD g_VBoxVDbgFCheckTexBlt;
73extern DWORD g_VBoxVDbgFCheckScSync;
74
75extern DWORD g_VBoxVDbgFSkipCheckTexBltDwmWndUpdate;
76
77extern DWORD g_VBoxVDbgCfgMaxDirectRts;
78extern DWORD g_VBoxVDbgCfgForceDummyDevCreate;
79
80extern struct VBOXWDDMDISP_DEVICE *g_VBoxVDbgInternalDevice;
81extern struct VBOXWDDMDISP_RESOURCE *g_VBoxVDbgInternalRc;
82
83extern DWORD g_VBoxVDbgCfgCreateSwapchainOnDdiOnce;
84
85# endif /* #ifndef IN_VBOXCRHGSMI */
86#endif
87
88#if defined(VBOXWDDMDISP_DEBUG) || defined(VBOX_WDDMDISP_WITH_PROFILE)
89/* log enable flags */
90extern DWORD g_VBoxVDbgFLogRel;
91extern DWORD g_VBoxVDbgFLog;
92extern DWORD g_VBoxVDbgFLogFlow;
93#endif
94
95#ifdef VBOXWDDMDISP_DEBUG_VEHANDLER
96void vboxVDbgVEHandlerRegister();
97void vboxVDbgVEHandlerUnregister();
98#endif
99
100#if defined(LOG_TO_BACKDOOR_DRV) || defined(VBOXWDDMDISP_DEBUG_PRINTDRV)
101# define DbgPrintDrv(_m) do { vboxDispLogDrvF _m; } while (0)
102# define DbgPrintDrvRel(_m) do { vboxDispLogDrvF _m; } while (0)
103# define DbgPrintDrvFlow(_m) do { vboxDispLogDrvF _m; } while (0)
104#else
105# define DbgPrintDrv(_m) do { } while (0)
106# define DbgPrintDrvRel(_m) do { } while (0)
107# define DbgPrintDrvFlow(_m) do { } while (0)
108#endif
109
110#ifdef VBOXWDDMDISP_DEBUG_PRINT
111# define DbgPrintUsr(_m) do { vboxDispLogDbgPrintF _m; } while (0)
112# define DbgPrintUsrRel(_m) do { vboxDispLogDbgPrintF _m; } while (0)
113# define DbgPrintUsrFlow(_m) do { vboxDispLogDbgPrintF _m; } while (0)
114#else
115# define DbgPrintUsr(_m) do { } while (0)
116# define DbgPrintUsrRel(_m) do { } while (0)
117# define DbgPrintUsrFlow(_m) do { } while (0)
118#endif
119
120#if defined(VBOXWDDMDISP_DEBUG) || defined(VBOX_WDDMDISP_WITH_PROFILE)
121#define vboxVDbgInternalLog(_p) if (g_VBoxVDbgFLog) { _p }
122#define vboxVDbgInternalLogFlow(_p) if (g_VBoxVDbgFLogFlow) { _p }
123#define vboxVDbgInternalLogRel(_p) if (g_VBoxVDbgFLogRel) { _p }
124#else
125#define vboxVDbgInternalLog(_p) do {} while (0)
126#define vboxVDbgInternalLogFlow(_p) do {} while (0)
127#define vboxVDbgInternalLogRel(_p) do { _p } while (0)
128#endif
129
130/* @todo: remove these from the code and from here */
131#define vboxVDbgPrint(_m) LOG_EXACT(_m)
132#define vboxVDbgPrintF(_m) LOGF_EXACT(_m)
133#define vboxVDbgPrintR(_m) LOGREL_EXACT(_m)
134
135#define vboxVDbgInternalLogLogger(_m) do { \
136 vboxVDbgInternalLog( \
137 Log(_m); \
138 DbgPrintUsr(_m); \
139 DbgPrintDrv(_m); \
140 ); \
141 } while (0)
142
143#define vboxVDbgInternalLogFlowLogger(_m) do { \
144 vboxVDbgInternalLogFlow( \
145 LogFlow(_m); \
146 DbgPrintUsrFlow(_m); \
147 DbgPrintDrvFlow(_m); \
148 ); \
149 } while (0)
150
151#define vboxVDbgInternalLogRelLogger(_m) do { \
152 vboxVDbgInternalLogRel( \
153 LogRel(_m); \
154 DbgPrintUsrRel(_m); \
155 DbgPrintDrvRel(_m); \
156 ); \
157 } while (0)
158
159#if defined(VBOXWDDMDISP_DEBUG) || defined(VBOX_WDDMDISP_WITH_PROFILE)
160extern DWORD g_VBoxVDbgPid;
161extern LONG g_VBoxVDbgFIsDwm;
162#define VBOXVDBG_CHECK_EXE(_pszName) (vboxVDbgDoCheckExe(_pszName))
163#define VBOXVDBG_IS_DWM() (!!(g_VBoxVDbgFIsDwm >=0 ? g_VBoxVDbgFIsDwm : (g_VBoxVDbgFIsDwm = VBOXVDBG_CHECK_EXE("dwm.exe"))))
164BOOL vboxVDbgDoCheckExe(const char * pszName);
165#endif
166#if defined(VBOXWDDMDISP_DEBUG) || defined(LOG_TO_BACKDOOR_DRV)
167
168#define VBOXVDBG_STRCASE(_t) \
169 case _t: return #_t;
170#define VBOXVDBG_STRCASE_UNKNOWN() \
171 default: Assert(0); return "Unknown";
172
173DECLINLINE(const char*) vboxDispLogD3DRcType(D3DRESOURCETYPE enmType)
174{
175 switch (enmType)
176 {
177 VBOXVDBG_STRCASE(D3DRTYPE_SURFACE);
178 VBOXVDBG_STRCASE(D3DRTYPE_VOLUME);
179 VBOXVDBG_STRCASE(D3DRTYPE_TEXTURE);
180 VBOXVDBG_STRCASE(D3DRTYPE_VOLUMETEXTURE);
181 VBOXVDBG_STRCASE(D3DRTYPE_CUBETEXTURE);
182 VBOXVDBG_STRCASE(D3DRTYPE_VERTEXBUFFER);
183 VBOXVDBG_STRCASE(D3DRTYPE_INDEXBUFFER);
184 VBOXVDBG_STRCASE_UNKNOWN();
185 }
186}
187
188#include "VBoxDispMpLogger.h"
189
190VBOXDISPMPLOGGER_DECL(void) VBoxDispMpLoggerDumpD3DCAPS9(struct _D3DCAPS9 *pCaps);
191
192void vboxDispLogDrvF(char * szString, ...);
193
194# define vboxDispDumpD3DCAPS9(_pCaps) do { VBoxDispMpLoggerDumpD3DCAPS9(_pCaps); } while (0)
195#else
196# define vboxDispDumpD3DCAPS9(_pCaps) do { } while (0)
197#endif
198
199#ifdef VBOXWDDMDISP_DEBUG
200
201void vboxDispLogDbgPrintF(char * szString, ...);
202
203# ifndef IN_VBOXCRHGSMI
204typedef struct VBOXWDDMDISP_ALLOCATION *PVBOXWDDMDISP_ALLOCATION;
205typedef struct VBOXWDDMDISP_RESOURCE *PVBOXWDDMDISP_RESOURCE;
206
207#define VBOXVDBG_DUMP_TYPEF_FLOW 0x00000001
208#define VBOXVDBG_DUMP_TYPEF_CONTENTS 0x00000002
209#define VBOXVDBG_DUMP_TYPEF_DONT_BREAK_ON_CONTENTS 0x00000004
210#define VBOXVDBG_DUMP_TYPEF_BREAK_ON_FLOW 0x00000008
211#define VBOXVDBG_DUMP_TYPEF_SHARED_ONLY 0x00000010
212
213#define VBOXVDBG_DUMP_FLAGS_IS_SETANY(_fFlags, _Value) (((_fFlags) & (_Value)) != 0)
214#define VBOXVDBG_DUMP_FLAGS_IS_SET(_fFlags, _Value) (((_fFlags) & (_Value)) == (_Value))
215#define VBOXVDBG_DUMP_FLAGS_IS_CLEARED(_fFlags, _Value) (((_fFlags) & (_Value)) == 0)
216#define VBOXVDBG_DUMP_FLAGS_CLEAR(_fFlags, _Value) ((_fFlags) & (~(_Value)))
217#define VBOXVDBG_DUMP_FLAGS_SET(_fFlags, _Value) ((_fFlags) | (_Value))
218
219#define VBOXVDBG_DUMP_TYPE_ENABLED(_fFlags) (VBOXVDBG_DUMP_FLAGS_IS_SETANY(_fFlags, VBOXVDBG_DUMP_TYPEF_FLOW | VBOXVDBG_DUMP_TYPEF_CONTENTS))
220#define VBOXVDBG_DUMP_TYPE_ENABLED_FOR_INFO(_pInfo, _fFlags) ( \
221 VBOXVDBG_DUMP_TYPE_ENABLED(_fFlags) \
222 && ( \
223 VBOXVDBG_DUMP_FLAGS_IS_CLEARED(_fFlags, VBOXVDBG_DUMP_TYPEF_SHARED_ONLY) \
224 || ((_pInfo)->pAlloc && (_pInfo)->pAlloc->pRc->aAllocations[0].hSharedHandle) \
225 ))
226
227#define VBOXVDBG_DUMP_TYPE_FLOW_ONLY(_fFlags) (VBOXVDBG_DUMP_FLAGS_IS_SET(_fFlags, VBOXVDBG_DUMP_TYPEF_FLOW) \
228 && VBOXVDBG_DUMP_FLAGS_IS_CLEARED(_fFlags, VBOXVDBG_DUMP_TYPEF_CONTENTS))
229#define VBOXVDBG_DUMP_TYPE_CONTENTS(_fFlags) (VBOXVDBG_DUMP_FLAGS_IS_SET(_fFlags, VBOXVDBG_DUMP_TYPEF_CONTENTS))
230#define VBOXVDBG_DUMP_TYPE_GET_FLOW_ONLY(_fFlags) ( \
231 VBOXVDBG_DUMP_FLAGS_SET( \
232 VBOXVDBG_DUMP_FLAGS_CLEAR(_fFlags, VBOXVDBG_DUMP_TYPEF_CONTENTS), \
233 VBOXVDBG_DUMP_TYPEF_FLOW) \
234 )
235
236VOID vboxVDbgDoDumpAllocRect(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, RECT *pRect, const char* pSuffix, DWORD fFlags);
237VOID vboxVDbgDoDumpRcRect(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DResource9 *pD3DRc, RECT *pRect, const char * pSuffix, DWORD fFlags);
238VOID vboxVDbgDoDumpLockUnlockSurfTex(const char * pPrefix, const VBOXWDDMDISP_ALLOCATION *pAlloc, const char * pSuffix, DWORD fFlags);
239VOID vboxVDbgDoDumpRt(const char * pPrefix, struct VBOXWDDMDISP_DEVICE *pDevice, const char * pSuffix, DWORD fFlags);
240VOID vboxVDbgDoDumpBb(const char * pPrefix, IDirect3DSwapChain9 *pSwapchainIf, const char * pSuffix, DWORD fFlags);
241VOID vboxVDbgDoDumpFb(const char * pPrefix, IDirect3DSwapChain9 *pSwapchainIf, const char * pSuffix, DWORD fFlags);
242VOID vboxVDbgDoDumpSamplers(const char * pPrefix, struct VBOXWDDMDISP_DEVICE *pDevice, const char * pSuffix, DWORD fFlags);
243
244void vboxVDbgDoPrintRect(const char * pPrefix, const RECT *pRect, const char * pSuffix);
245void vboxVDbgDoPrintAlloc(const char * pPrefix, const VBOXWDDMDISP_RESOURCE *pRc, uint32_t iAlloc, const char * pSuffix);
246
247VOID vboxVDbgDoDumpLockSurfTex(const char * pPrefix, const D3DDDIARG_LOCK* pData, const char * pSuffix, DWORD fFlags);
248VOID vboxVDbgDoDumpUnlockSurfTex(const char * pPrefix, const D3DDDIARG_UNLOCK* pData, const char * pSuffix, DWORD fFlags);
249
250BOOL vboxVDbgDoCheckRectsMatch(const VBOXWDDMDISP_RESOURCE *pDstRc, uint32_t iDstAlloc,
251 const VBOXWDDMDISP_RESOURCE *pSrcRc, uint32_t iSrcAlloc,
252 const RECT *pDstRect,
253 const RECT *pSrcRect,
254 BOOL fBreakOnMismatch);
255
256VOID vboxVDbgDoPrintLopLastCmd(const char* pszDesc);
257
258HRESULT vboxVDbgTimerStart(HANDLE hTimerQueue, HANDLE *phTimer, DWORD msTimeout);
259HRESULT vboxVDbgTimerStop(HANDLE hTimerQueue, HANDLE hTimer);
260
261#define VBOXVDBG_IS_PID(_pid) ((_pid) == (g_VBoxVDbgPid ? g_VBoxVDbgPid : (g_VBoxVDbgPid = GetCurrentProcessId())))
262#define VBOXVDBG_IS_DUMP_ALLOWED_PID(_pid) (((int)(_pid)) > 0 ? VBOXVDBG_IS_PID(_pid) : !VBOXVDBG_IS_PID(-((int)(_pid))))
263
264#define VBOXVDBG_ASSERT_IS_DWM(_bDwm) do { \
265 Assert((!VBOXVDBG_IS_DWM()) == (!(_bDwm))); \
266 } while (0)
267
268#define VBOXVDBG_DUMP_FLAGS_FOR_TYPE(_type) g_VBoxVDbgFDump##_type
269#define VBOXVDBG_BREAK_FLAGS_FOR_TYPE(_type) g_VBoxVDbgFBreak##_type
270#define VBOXVDBG_CHECK_FLAGS_FOR_TYPE(_type) g_VBoxVDbgFCheck##_type
271#define VBOXVDBG_IS_DUMP_ALLOWED(_type) ( VBOXVDBG_DUMP_TYPE_ENABLED(VBOXVDBG_DUMP_FLAGS_FOR_TYPE(_type)) )
272
273#define VBOXVDBG_IS_BREAK_ALLOWED(_type) ( !!VBOXVDBG_BREAK_FLAGS_FOR_TYPE(_type) )
274
275#define VBOXVDBG_IS_CHECK_ALLOWED(_type) ( !!VBOXVDBG_CHECK_FLAGS_FOR_TYPE(_type) )
276
277#define VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pRc) (\
278 (_pRc)->RcDesc.fFlags.SharedResource \
279 && VBOXVDBG_IS_DUMP_ALLOWED(Shared) \
280 )
281
282#define VBOXVDBG_IS_BREAK_SHARED_ALLOWED(_pRc) (\
283 (_pRc)->RcDesc.fFlags.SharedResource \
284 && VBOXVDBG_IS_BREAK_ALLOWED(Shared) \
285 )
286
287#define VBOXVDBG_BREAK_SHARED(_pRc) do { \
288 if (VBOXVDBG_IS_BREAK_SHARED_ALLOWED(_pRc)) { \
289 vboxVDbgPrint(("Break on shared access: Rc(0x%p), SharedHandle(0x%p)\n", (_pRc), (_pRc)->aAllocations[0].hSharedHandle)); \
290 AssertFailed(); \
291 } \
292 } while (0)
293
294#define VBOXVDBG_BREAK_DDI() do { \
295 if (VBOXVDBG_IS_BREAK_ALLOWED(Ddi)) { \
296 AssertFailed(); \
297 } \
298 } while (0)
299
300#define VBOXVDBG_LOOP_LAST() do { vboxVDbgLoop = 0; } while (0)
301
302#define VBOXVDBG_LOOP(_op) do { \
303 DWORD vboxVDbgLoop = 1; \
304 do { \
305 _op; \
306 } while (vboxVDbgLoop); \
307 } while (0)
308
309#define VBOXVDBG_CHECK_SMSYNC(_pRc) do { \
310 if (VBOXVDBG_IS_CHECK_ALLOWED(SysMemSync)) { \
311 vboxWddmDbgRcSynchMemCheck((_pRc)); \
312 } \
313 } while (0)
314
315#define VBOXVDBG_DUMP_RECTS_INIT(_d) DWORD vboxVDbgDumpRects = _d; NOREF(vboxVDbgDumpRects)
316#define VBOXVDBG_DUMP_RECTS_FORCE() vboxVDbgDumpRects = 1;
317#define VBOXVDBG_DUMP_RECTS_FORCED() (!!vboxVDbgDumpRects)
318
319#define VBOXVDBG_CHECK_RECTS(_opRests, _opDump, _pszOpName, _pDstRc, _iDstAlloc, _pSrcRc, _iSrcAlloc, _pDstRect, _pSrcRect) do { \
320 VBOXVDBG_LOOP(\
321 VBOXVDBG_DUMP_RECTS_INIT(0); \
322 _opRests; \
323 if (vboxVDbgDoCheckRectsMatch(_pDstRc, _iDstAlloc, _pSrcRc, _iSrcAlloc, _pDstRect, _pSrcRect, FALSE)) { \
324 VBOXVDBG_LOOP_LAST(); \
325 } \
326 else \
327 { \
328 VBOXVDBG_DUMP_RECTS_FORCE(); \
329 vboxVDbgPrint(("vboxVDbgDoCheckRectsMatch failed! The " _pszOpName " will be re-done so it can be debugged\n")); \
330 vboxVDbgDoPrintLopLastCmd("Don't redo the" _pszOpName); \
331 Assert(0); \
332 } \
333 _opDump; \
334 ); \
335 } while (0)
336
337#define VBOXVDBG_DEV_CHECK_SHARED(_pDevice, _pIsShared) do { \
338 *(_pIsShared) = FALSE; \
339 for (UINT i = 0; i < (_pDevice)->cRTs; ++i) { \
340 PVBOXWDDMDISP_ALLOCATION pRtVar = (_pDevice)->apRTs[i]; \
341 if (pRtVar && pRtVar->pRc->RcDesc.fFlags.SharedResource) { *(_pIsShared) = TRUE; break; } \
342 } \
343 if (!*(_pIsShared)) { \
344 for (UINT i = 0, iSampler = 0; iSampler < (_pDevice)->cSamplerTextures; ++i) { \
345 Assert(i < RT_ELEMENTS((_pDevice)->aSamplerTextures)); \
346 if (!(_pDevice)->aSamplerTextures[i]) continue; \
347 ++iSampler; \
348 if (!(_pDevice)->aSamplerTextures[i]->RcDesc.fFlags.SharedResource) continue; \
349 *(_pIsShared) = TRUE; break; \
350 } \
351 } \
352 } while (0)
353
354#define VBOXVDBG_IS_DUMP_SHARED_ALLOWED_DEV(_pDevice, _pIsAllowed) do { \
355 VBOXVDBG_DEV_CHECK_SHARED(_pDevice, _pIsAllowed); \
356 if (*(_pIsAllowed)) \
357 { \
358 *(_pIsAllowed) = VBOXVDBG_IS_DUMP_ALLOWED(Shared); \
359 } \
360 } while (0)
361
362#define VBOXVDBG_IS_BREAK_SHARED_ALLOWED_DEV(_pDevice, _pIsAllowed) do { \
363 VBOXVDBG_DEV_CHECK_SHARED(_pDevice, _pIsAllowed); \
364 if (*(_pIsAllowed)) \
365 { \
366 *(_pIsAllowed) = VBOXVDBG_IS_BREAK_ALLOWED(Shared); \
367 } \
368 } while (0)
369
370#define VBOXVDBG_DUMP_DRAWPRIM_ENTER(_pDevice) do { \
371 BOOL fDumpShaded = FALSE; \
372 VBOXVDBG_IS_DUMP_SHARED_ALLOWED_DEV(_pDevice, &fDumpShaded); \
373 if (fDumpShaded \
374 || VBOXVDBG_IS_DUMP_ALLOWED(DrawPrim)) \
375 { \
376 vboxVDbgDoDumpRt("==>"__FUNCTION__": Rt: ", (_pDevice), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim)); \
377 vboxVDbgDoDumpSamplers("==>"__FUNCTION__": Sl: ", (_pDevice), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared) | 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), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim)); \
388 vboxVDbgDoDumpSamplers("<=="__FUNCTION__": Sl: ", (_pDevice), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim)); \
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(_type) | 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, "", fFlags); \
469 if (_pDstRect) \
470 { \
471 Rect = *((RECT*)(_pDstRect)); \
472 pRect = &Rect; \
473 } \
474 else \
475 pRect = NULL; \
476 vboxVDbgDoDumpRcRect(_str __FUNCTION__" Dst: ", (_pDstAlloc), (_pDstSurf), pRect, "", fFlags); \
477 } \
478 } while (0)
479
480#define VBOXVDBG_DUMP_BLT_ENTER(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
481 VBOXVDBG_DUMP_STRETCH_RECT(Blt, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
482
483#define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
484 VBOXVDBG_DUMP_STRETCH_RECT(Blt, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
485
486#define VBOXVDBG_DUMP_SWAPCHAIN_SYNC_ENTER(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
487 VBOXVDBG_DUMP_STRETCH_RECT(ScSync, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
488
489#define VBOXVDBG_DUMP_SWAPCHAIN_SYNC_LEAVE(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
490 VBOXVDBG_DUMP_STRETCH_RECT(ScSync, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
491
492#define VBOXVDBG_IS_SKIP_DWM_WND_UPDATE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) ( \
493 g_VBoxVDbgFSkipCheckTexBltDwmWndUpdate \
494 && ( \
495 VBOXVDBG_IS_DWM() \
496 && (_pSrcRc)->RcDesc.enmPool == D3DDDIPOOL_SYSTEMMEM \
497 && (_pSrcRc)->RcDesc.enmFormat == D3DDDIFMT_A8R8G8B8 \
498 && (_pSrcRc)->cAllocations == 1 \
499 && (_pDstRc)->RcDesc.enmPool == D3DDDIPOOL_VIDEOMEMORY \
500 && (_pDstRc)->RcDesc.enmFormat == D3DDDIFMT_A8R8G8B8 \
501 && (_pDstRc)->RcDesc.fFlags.RenderTarget \
502 && (_pDstRc)->RcDesc.fFlags.NotLockable \
503 && (_pDstRc)->cAllocations == 1 \
504 && (_pSrcRc)->aAllocations[0].SurfDesc.width == (_pDstRc)->aAllocations[0].SurfDesc.width \
505 && (_pSrcRc)->aAllocations[0].SurfDesc.height == (_pDstRc)->aAllocations[0].SurfDesc.height \
506 ) \
507 )
508
509#define VBOXVDBG_CHECK_TEXBLT(_opTexBlt, _pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { \
510 if (VBOXVDBG_IS_CHECK_ALLOWED(TexBlt)) { \
511 if (VBOXVDBG_IS_SKIP_DWM_WND_UPDATE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint)) \
512 { \
513 vboxVDbgPrint(("TEXBLT: skipping check for dwm wnd update\n")); \
514 } \
515 else \
516 { \
517 RECT DstRect; \
518 DstRect.left = (_pDstPoint)->x; \
519 DstRect.right = (_pDstPoint)->x + (_pSrcRect)->right - (_pSrcRect)->left; \
520 DstRect.top = (_pDstPoint)->y; \
521 DstRect.bottom = (_pDstPoint)->y + (_pSrcRect)->bottom - (_pSrcRect)->top; \
522 VBOXVDBG_CHECK_RECTS(\
523 VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint); \
524 _opTexBlt ,\
525 VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint), \
526 "TexBlt", \
527 _pDstRc, 0, _pSrcRc, 0, &DstRect, _pSrcRect); \
528 break; \
529 } \
530 } \
531 VBOXVDBG_DUMP_RECTS_INIT(0); \
532 VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint); \
533 _opTexBlt;\
534 VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint); \
535 } while (0)
536
537#define VBOXVDBG_CHECK_STRETCH_RECT(_type, _op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { \
538 if (VBOXVDBG_IS_CHECK_ALLOWED(_type)) { \
539 VBOXVDBG_CHECK_RECTS(\
540 VBOXVDBG_DUMP_STRETCH_RECT(_type, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect); \
541 _op ,\
542 VBOXVDBG_DUMP_STRETCH_RECT(_type, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect), \
543 #_type , \
544 _pDstAlloc->pRc, _pDstAlloc->iAlloc, _pSrcAlloc->pRc, _pSrcAlloc->iAlloc, _pDstRect, _pSrcRect); \
545 } \
546 else \
547 { \
548 VBOXVDBG_DUMP_RECTS_INIT(0); \
549 VBOXVDBG_DUMP_STRETCH_RECT(_type, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect); \
550 _op;\
551 VBOXVDBG_DUMP_STRETCH_RECT(_type, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect); \
552 } \
553 } while (0)
554
555#define VBOXVDBG_CHECK_BLT(_opBlt, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
556 VBOXVDBG_CHECK_STRETCH_RECT(Blt, _opBlt, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
557
558#define VBOXVDBG_CHECK_SWAPCHAIN_SYNC(_op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
559 VBOXVDBG_CHECK_STRETCH_RECT(ScSync, _op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
560
561#define VBOXVDBG_DUMP_SYNC_RT(_pBbSurf) do { \
562 if (VBOXVDBG_IS_DUMP_ALLOWED(RtSynch)) \
563 { \
564 vboxVDbgDoDumpRcRect("== "__FUNCTION__" Bb:\n", NULL, (_pBbSurf), NULL, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(RtSynch)); \
565 } \
566 } while (0)
567
568#define VBOXVDBG_DUMP_PRESENT_ENTER(_pDevice, _pSwapchain) do { \
569 if (VBOXVDBG_IS_DUMP_ALLOWED(PresentEnter)) { \
570 if (!(_pSwapchain)->fFlags.bRtReportingPresent) { \
571 vboxVDbgDoDumpBb("==>"__FUNCTION__" Bb:\n", (_pSwapchain)->pSwapChainIf, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(PresentEnter)); \
572 } \
573 else { \
574 PVBOXWDDMDISP_ALLOCATION pCurBb = vboxWddmSwapchainGetBb((_pSwapchain))->pAlloc; \
575 IDirect3DSurface9 *pSurf; \
576 HRESULT hr = vboxWddmSwapchainSurfGet(_pDevice, _pSwapchain, pCurBb, &pSurf); \
577 Assert(hr == S_OK); \
578 vboxVDbgDoDumpRcRect("== "__FUNCTION__" Bb:\n", pCurBb, pSurf, NULL, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(PresentEnter)); \
579 pSurf->Release(); \
580 } \
581 } \
582 } while (0)
583
584#define VBOXVDBG_DUMP_PRESENT_LEAVE(_pDevice, _pSwapchain) do { \
585 if (VBOXVDBG_IS_DUMP_ALLOWED(PresentLeave)) { \
586 if (!(_pSwapchain)->fFlags.bRtReportingPresent) { \
587 vboxVDbgDoDumpFb("<=="__FUNCTION__" Fb:\n", (_pSwapchain)->pSwapChainIf, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(PresentLeave)); \
588 } \
589 else { \
590 vboxVDbgPrint(("PRESENT_LEAVE: unsupported for Rt Reporting mode\n")); \
591 } \
592 } \
593 } while (0)
594
595
596#define VBOXVDBG_DUMP_FLUSH(_pDevice) do { \
597 if (VBOXVDBG_IS_DUMP_ALLOWED(Flush)) \
598 { \
599 vboxVDbgDoDumpRt("== "__FUNCTION__": Rt: ", (_pDevice), "", \
600 VBOXVDBG_DUMP_FLAGS_CLEAR(VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Flush), VBOXVDBG_DUMP_TYPEF_SHARED_ONLY)); \
601 }\
602 } while (0)
603
604#define VBOXVDBG_DUMP_LOCK_ST(_pData) do { \
605 if (VBOXVDBG_IS_DUMP_ALLOWED(Lock) \
606 || VBOXVDBG_IS_DUMP_ALLOWED(Unlock) \
607 ) \
608 { \
609 vboxVDbgDoDumpLockSurfTex("== "__FUNCTION__": ", (_pData), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Lock)); \
610 } \
611 } while (0)
612
613#define VBOXVDBG_DUMP_UNLOCK_ST(_pData) do { \
614 if (VBOXVDBG_IS_DUMP_ALLOWED(Unlock) \
615 ) \
616 { \
617 vboxVDbgDoDumpUnlockSurfTex("== "__FUNCTION__": ", (_pData), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Unlock)); \
618 } \
619 } while (0)
620
621
622#define VBOXVDBG_CREATE_CHECK_SWAPCHAIN() do { \
623 if (g_VBoxVDbgCfgCreateSwapchainOnDdiOnce && g_VBoxVDbgInternalRc) { \
624 PVBOXWDDMDISP_SWAPCHAIN pSwapchain; \
625 HRESULT hr = vboxWddmSwapchainCreateIfForRc(g_VBoxVDbgInternalDevice, g_VBoxVDbgInternalRc, &pSwapchain); \
626 Assert(hr == S_OK); \
627 g_VBoxVDbgInternalRc = NULL; \
628 g_VBoxVDbgCfgCreateSwapchainOnDdiOnce = 0; \
629 } \
630 } while (0)
631
632# endif /* # ifndef IN_VBOXCRHGSMI */
633#else
634#define VBOXVDBG_DUMP_DRAWPRIM_ENTER(_pDevice) do { } while (0)
635#define VBOXVDBG_DUMP_DRAWPRIM_LEAVE(_pDevice) do { } while (0)
636#define VBOXVDBG_DUMP_SETTEXTURE(_pRc) do { } while (0)
637#define VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { } while (0)
638#define VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { } while (0)
639#define VBOXVDBG_DUMP_BLT_ENTER(_pSrcRc, _pSrcSurf, _pSrcRect, _pDstRc, _pDstSurf, _pDstRect) do { } while (0)
640#define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcRc, _pSrcSurf, _pSrcRect, _pDstRc, _pDstSurf, _pDstRect) do { } while (0)
641#define VBOXVDBG_DUMP_SYNC_RT(_pBbSurf) do { } while (0)
642#define VBOXVDBG_DUMP_FLUSH(_pDevice) do { } while (0)
643#define VBOXVDBG_DUMP_LOCK_ST(_pData) do { } while (0)
644#define VBOXVDBG_DUMP_UNLOCK_ST(_pData) do { } while (0)
645#define VBOXVDBG_DUMP_PRESENT_ENTER(_pDevice, _pSwapchain) do { } while (0)
646#define VBOXVDBG_DUMP_PRESENT_LEAVE(_pDevice, _pSwapchain) do { } while (0)
647#define VBOXVDBG_BREAK_SHARED(_pRc) do { } while (0)
648#define VBOXVDBG_BREAK_SHARED_DEV(_pDevice) do { } while (0)
649#define VBOXVDBG_BREAK_DDI() do { } while (0)
650#define VBOXVDBG_CHECK_SMSYNC(_pRc) do { } while (0)
651#define VBOXVDBG_CHECK_BLT(_opBlt, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { _opBlt; } while (0)
652#define VBOXVDBG_CHECK_TEXBLT(_opTexBlt, _pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { _opTexBlt; } while (0)
653#define VBOXVDBG_ASSERT_IS_DWM(_bDwm) do { } while (0)
654#define VBOXVDBG_CHECK_SWAPCHAIN_SYNC(_op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { _op; } while (0)
655#define VBOXVDBG_CREATE_CHECK_SWAPCHAIN() do { } while (0)
656#endif
657
658
659#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