VirtualBox

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

Last change on this file since 46606 was 45132, checked in by vboxsync, 12 years ago

crOpenGL: seamles mode support impl; bugfizes & cleanup

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