VirtualBox

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

Last change on this file since 82968 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 25.8 KB
Line 
1/* $Id: VBoxDispDbg.h 82968 2020-02-04 10:35:17Z vboxsync $ */
2/** @file
3 * VBoxVideo Display D3D User mode dll
4 */
5
6/*
7 * Copyright (C) 2011-2020 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef GA_INCLUDED_SRC_WINNT_Graphics_Video_disp_wddm_VBoxDispDbg_h
19#define GA_INCLUDED_SRC_WINNT_Graphics_Video_disp_wddm_VBoxDispDbg_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#define VBOX_VIDEO_LOG_NAME "VBoxD3D"
25#define VBOX_VIDEO_LOG_LOGGER vboxVDbgInternalLogLogger
26#define VBOX_VIDEO_LOGREL_LOGGER vboxVDbgInternalLogRelLogger
27#define VBOX_VIDEO_LOGFLOW_LOGGER vboxVDbgInternalLogFlowLogger
28#define VBOX_VIDEO_LOG_FN_FMT "%s"
29
30#include "../../common/VBoxVideoLog.h"
31
32#ifdef DEBUG
33/* debugging configuration flags */
34
35/* Adds vectored exception handler to be able to catch non-debug UM exceptions in kernel debugger. */
36#define VBOXWDDMDISP_DEBUG_VEHANDLER
37
38/* generic debugging facilities & extra data checks */
39# define VBOXWDDMDISP_DEBUG
40/* for some reason when debugging with VirtualKD, user-mode DbgPrint's are discarded
41 * the workaround so far is to pass the log info to the kernel driver and DbgPrint'ed from there,
42 * which is enabled by this define */
43//# define VBOXWDDMDISP_DEBUG_PRINTDRV
44
45/* Uncomment to use OutputDebugString */
46//#define VBOXWDDMDISP_DEBUG_PRINT
47
48/* disable shared resource creation with wine */
49//# define VBOXWDDMDISP_DEBUG_NOSHARED
50
51//# define VBOXWDDMDISP_DEBUG_PRINT_SHARED_CREATE
52//# define VBOXWDDMDISP_DEBUG_TIMER
53
54/* debug config vars */
55extern DWORD g_VBoxVDbgFDumpSetTexture;
56extern DWORD g_VBoxVDbgFDumpDrawPrim;
57extern DWORD g_VBoxVDbgFDumpTexBlt;
58extern DWORD g_VBoxVDbgFDumpBlt;
59extern DWORD g_VBoxVDbgFDumpRtSynch;
60extern DWORD g_VBoxVDbgFDumpFlush;
61extern DWORD g_VBoxVDbgFDumpShared;
62extern DWORD g_VBoxVDbgFDumpLock;
63extern DWORD g_VBoxVDbgFDumpUnlock;
64extern DWORD g_VBoxVDbgFDumpPresentEnter;
65extern DWORD g_VBoxVDbgFDumpPresentLeave;
66extern DWORD g_VBoxVDbgFDumpScSync;
67
68extern DWORD g_VBoxVDbgFBreakShared;
69extern DWORD g_VBoxVDbgFBreakDdi;
70
71extern DWORD g_VBoxVDbgFCheckSysMemSync;
72extern DWORD g_VBoxVDbgFCheckBlt;
73extern DWORD g_VBoxVDbgFCheckTexBlt;
74extern DWORD g_VBoxVDbgFCheckScSync;
75
76extern DWORD g_VBoxVDbgFSkipCheckTexBltDwmWndUpdate;
77
78extern DWORD g_VBoxVDbgCfgMaxDirectRts;
79extern DWORD g_VBoxVDbgCfgForceDummyDevCreate;
80
81extern struct VBOXWDDMDISP_DEVICE *g_VBoxVDbgInternalDevice;
82extern struct VBOXWDDMDISP_RESOURCE *g_VBoxVDbgInternalRc;
83
84#endif
85
86#if defined(VBOXWDDMDISP_DEBUG)
87/* log enable flags */
88extern DWORD g_VBoxVDbgFLogRel;
89extern DWORD g_VBoxVDbgFLog;
90extern DWORD g_VBoxVDbgFLogFlow;
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#if defined(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)
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
171DECLINLINE(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
201typedef struct VBOXWDDMDISP_ALLOCATION *PVBOXWDDMDISP_ALLOCATION;
202typedef struct VBOXWDDMDISP_RESOURCE *PVBOXWDDMDISP_RESOURCE;
203
204#define VBOXVDBG_DUMP_TYPEF_FLOW 0x00000001
205#define VBOXVDBG_DUMP_TYPEF_CONTENTS 0x00000002
206#define VBOXVDBG_DUMP_TYPEF_DONT_BREAK_ON_CONTENTS 0x00000004
207#define VBOXVDBG_DUMP_TYPEF_BREAK_ON_FLOW 0x00000008
208#define VBOXVDBG_DUMP_TYPEF_SHARED_ONLY 0x00000010
209
210#define VBOXVDBG_DUMP_FLAGS_IS_SETANY(_fFlags, _Value) (((_fFlags) & (_Value)) != 0)
211#define VBOXVDBG_DUMP_FLAGS_IS_SET(_fFlags, _Value) (((_fFlags) & (_Value)) == (_Value))
212#define VBOXVDBG_DUMP_FLAGS_IS_CLEARED(_fFlags, _Value) (((_fFlags) & (_Value)) == 0)
213#define VBOXVDBG_DUMP_FLAGS_CLEAR(_fFlags, _Value) ((_fFlags) & (~(_Value)))
214#define VBOXVDBG_DUMP_FLAGS_SET(_fFlags, _Value) ((_fFlags) | (_Value))
215
216#define VBOXVDBG_DUMP_TYPE_ENABLED(_fFlags) (VBOXVDBG_DUMP_FLAGS_IS_SETANY(_fFlags, VBOXVDBG_DUMP_TYPEF_FLOW | VBOXVDBG_DUMP_TYPEF_CONTENTS))
217#define VBOXVDBG_DUMP_TYPE_ENABLED_FOR_INFO(_pInfo, _fFlags) ( \
218 VBOXVDBG_DUMP_TYPE_ENABLED(_fFlags) \
219 && ( \
220 VBOXVDBG_DUMP_FLAGS_IS_CLEARED(_fFlags, VBOXVDBG_DUMP_TYPEF_SHARED_ONLY) \
221 || ((_pInfo)->pAlloc && (_pInfo)->pAlloc->pRc->aAllocations[0].hSharedHandle) \
222 ))
223
224#define VBOXVDBG_DUMP_TYPE_FLOW_ONLY(_fFlags) (VBOXVDBG_DUMP_FLAGS_IS_SET(_fFlags, VBOXVDBG_DUMP_TYPEF_FLOW) \
225 && VBOXVDBG_DUMP_FLAGS_IS_CLEARED(_fFlags, VBOXVDBG_DUMP_TYPEF_CONTENTS))
226#define VBOXVDBG_DUMP_TYPE_CONTENTS(_fFlags) (VBOXVDBG_DUMP_FLAGS_IS_SET(_fFlags, VBOXVDBG_DUMP_TYPEF_CONTENTS))
227#define VBOXVDBG_DUMP_TYPE_GET_FLOW_ONLY(_fFlags) ( \
228 VBOXVDBG_DUMP_FLAGS_SET( \
229 VBOXVDBG_DUMP_FLAGS_CLEAR(_fFlags, VBOXVDBG_DUMP_TYPEF_CONTENTS), \
230 VBOXVDBG_DUMP_TYPEF_FLOW) \
231 )
232
233VOID vboxVDbgDoDumpAllocRect(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, RECT *pRect, const char* pSuffix, DWORD fFlags);
234VOID vboxVDbgDoDumpRcRect(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DResource9 *pD3DRc, RECT *pRect, const char * pSuffix, DWORD fFlags);
235VOID vboxVDbgDoDumpLockUnlockSurfTex(const char * pPrefix, const VBOXWDDMDISP_ALLOCATION *pAlloc, const char * pSuffix, DWORD fFlags);
236VOID vboxVDbgDoDumpRt(const char * pPrefix, struct VBOXWDDMDISP_DEVICE *pDevice, const char * pSuffix, DWORD fFlags);
237VOID vboxVDbgDoDumpSamplers(const char * pPrefix, struct VBOXWDDMDISP_DEVICE *pDevice, const char * pSuffix, DWORD fFlags);
238
239void vboxVDbgDoPrintRect(const char * pPrefix, const RECT *pRect, const char * pSuffix);
240void vboxVDbgDoPrintAlloc(const char * pPrefix, const VBOXWDDMDISP_RESOURCE *pRc, uint32_t iAlloc, const char * pSuffix);
241
242VOID vboxVDbgDoDumpLockSurfTex(const char * pPrefix, const D3DDDIARG_LOCK* pData, const char * pSuffix, DWORD fFlags);
243VOID vboxVDbgDoDumpUnlockSurfTex(const char * pPrefix, const D3DDDIARG_UNLOCK* pData, const char * pSuffix, DWORD fFlags);
244
245BOOL vboxVDbgDoCheckRectsMatch(const VBOXWDDMDISP_RESOURCE *pDstRc, uint32_t iDstAlloc,
246 const VBOXWDDMDISP_RESOURCE *pSrcRc, uint32_t iSrcAlloc,
247 const RECT *pDstRect,
248 const RECT *pSrcRect,
249 BOOL fBreakOnMismatch);
250
251VOID vboxVDbgDoPrintLopLastCmd(const char* pszDesc);
252
253HRESULT vboxVDbgTimerStart(HANDLE hTimerQueue, HANDLE *phTimer, DWORD msTimeout);
254HRESULT vboxVDbgTimerStop(HANDLE hTimerQueue, HANDLE hTimer);
255
256#define VBOXVDBG_IS_PID(_pid) ((_pid) == (g_VBoxVDbgPid ? g_VBoxVDbgPid : (g_VBoxVDbgPid = GetCurrentProcessId())))
257#define VBOXVDBG_IS_DUMP_ALLOWED_PID(_pid) (((int)(_pid)) > 0 ? VBOXVDBG_IS_PID(_pid) : !VBOXVDBG_IS_PID(-((int)(_pid))))
258
259#define VBOXVDBG_ASSERT_IS_DWM(_bDwm) do { \
260 Assert((!VBOXVDBG_IS_DWM()) == (!(_bDwm))); \
261 } while (0)
262
263#define VBOXVDBG_DUMP_FLAGS_FOR_TYPE(_type) g_VBoxVDbgFDump##_type
264#define VBOXVDBG_BREAK_FLAGS_FOR_TYPE(_type) g_VBoxVDbgFBreak##_type
265#define VBOXVDBG_CHECK_FLAGS_FOR_TYPE(_type) g_VBoxVDbgFCheck##_type
266#define VBOXVDBG_IS_DUMP_ALLOWED(_type) ( VBOXVDBG_DUMP_TYPE_ENABLED(VBOXVDBG_DUMP_FLAGS_FOR_TYPE(_type)) )
267
268#define VBOXVDBG_IS_BREAK_ALLOWED(_type) ( !!VBOXVDBG_BREAK_FLAGS_FOR_TYPE(_type) )
269
270#define VBOXVDBG_IS_CHECK_ALLOWED(_type) ( !!VBOXVDBG_CHECK_FLAGS_FOR_TYPE(_type) )
271
272#define VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pRc) (\
273 (_pRc)->RcDesc.fFlags.SharedResource \
274 && VBOXVDBG_IS_DUMP_ALLOWED(Shared) \
275 )
276
277#define VBOXVDBG_IS_BREAK_SHARED_ALLOWED(_pRc) (\
278 (_pRc)->RcDesc.fFlags.SharedResource \
279 && VBOXVDBG_IS_BREAK_ALLOWED(Shared) \
280 )
281
282#define VBOXVDBG_BREAK_SHARED(_pRc) do { \
283 if (VBOXVDBG_IS_BREAK_SHARED_ALLOWED(_pRc)) { \
284 vboxVDbgPrint(("Break on shared access: Rc(0x%p), SharedHandle(0x%p)\n", (_pRc), (_pRc)->aAllocations[0].hSharedHandle)); \
285 AssertFailed(); \
286 } \
287 } while (0)
288
289#define VBOXVDBG_BREAK_DDI() do { \
290 if (VBOXVDBG_IS_BREAK_ALLOWED(Ddi)) { \
291 AssertFailed(); \
292 } \
293 } while (0)
294
295#define VBOXVDBG_LOOP_LAST() do { vboxVDbgLoop = 0; } while (0)
296
297#define VBOXVDBG_LOOP(_op) do { \
298 DWORD vboxVDbgLoop = 1; \
299 do { \
300 _op; \
301 } while (vboxVDbgLoop); \
302 } while (0)
303
304#define VBOXVDBG_CHECK_SMSYNC(_pRc) do { \
305 if (VBOXVDBG_IS_CHECK_ALLOWED(SysMemSync)) { \
306 vboxWddmDbgRcSynchMemCheck((_pRc)); \
307 } \
308 } while (0)
309
310#define VBOXVDBG_DUMP_RECTS_INIT(_d) DWORD vboxVDbgDumpRects = _d; NOREF(vboxVDbgDumpRects)
311#define VBOXVDBG_DUMP_RECTS_FORCE() vboxVDbgDumpRects = 1;
312#define VBOXVDBG_DUMP_RECTS_FORCED() (!!vboxVDbgDumpRects)
313
314#define VBOXVDBG_CHECK_RECTS(_opRests, _opDump, _pszOpName, _pDstRc, _iDstAlloc, _pSrcRc, _iSrcAlloc, _pDstRect, _pSrcRect) do { \
315 VBOXVDBG_LOOP(\
316 VBOXVDBG_DUMP_RECTS_INIT(0); \
317 _opRests; \
318 if (vboxVDbgDoCheckRectsMatch(_pDstRc, _iDstAlloc, _pSrcRc, _iSrcAlloc, _pDstRect, _pSrcRect, FALSE)) { \
319 VBOXVDBG_LOOP_LAST(); \
320 } \
321 else \
322 { \
323 VBOXVDBG_DUMP_RECTS_FORCE(); \
324 vboxVDbgPrint(("vboxVDbgDoCheckRectsMatch failed! The " _pszOpName " will be re-done so it can be debugged\n")); \
325 vboxVDbgDoPrintLopLastCmd("Don't redo the" _pszOpName); \
326 Assert(0); \
327 } \
328 _opDump; \
329 ); \
330 } while (0)
331
332#define VBOXVDBG_DEV_CHECK_SHARED(_pDevice, _pIsShared) do { \
333 *(_pIsShared) = FALSE; \
334 for (UINT i = 0; i < (_pDevice)->cRTs; ++i) { \
335 PVBOXWDDMDISP_ALLOCATION pRtVar = (_pDevice)->apRTs[i]; \
336 if (pRtVar && pRtVar->pRc->RcDesc.fFlags.SharedResource) { *(_pIsShared) = TRUE; break; } \
337 } \
338 if (!*(_pIsShared)) { \
339 for (UINT i = 0, iSampler = 0; iSampler < (_pDevice)->cSamplerTextures; ++i) { \
340 Assert(i < RT_ELEMENTS((_pDevice)->aSamplerTextures)); \
341 if (!(_pDevice)->aSamplerTextures[i]) continue; \
342 ++iSampler; \
343 if (!(_pDevice)->aSamplerTextures[i]->RcDesc.fFlags.SharedResource) continue; \
344 *(_pIsShared) = TRUE; break; \
345 } \
346 } \
347 } while (0)
348
349#define VBOXVDBG_IS_DUMP_SHARED_ALLOWED_DEV(_pDevice, _pIsAllowed) do { \
350 VBOXVDBG_DEV_CHECK_SHARED(_pDevice, _pIsAllowed); \
351 if (*(_pIsAllowed)) \
352 { \
353 *(_pIsAllowed) = VBOXVDBG_IS_DUMP_ALLOWED(Shared); \
354 } \
355 } while (0)
356
357#define VBOXVDBG_IS_BREAK_SHARED_ALLOWED_DEV(_pDevice, _pIsAllowed) do { \
358 VBOXVDBG_DEV_CHECK_SHARED(_pDevice, _pIsAllowed); \
359 if (*(_pIsAllowed)) \
360 { \
361 *(_pIsAllowed) = VBOXVDBG_IS_BREAK_ALLOWED(Shared); \
362 } \
363 } while (0)
364
365#define VBOXVDBG_DUMP_DRAWPRIM_ENTER(_pDevice) do { \
366 BOOL fDumpShaded = FALSE; \
367 VBOXVDBG_IS_DUMP_SHARED_ALLOWED_DEV(_pDevice, &fDumpShaded); \
368 if (fDumpShaded \
369 || VBOXVDBG_IS_DUMP_ALLOWED(DrawPrim)) \
370 { \
371 vboxVDbgDoDumpRt("==>"__FUNCTION__": Rt: ", (_pDevice), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim)); \
372 vboxVDbgDoDumpSamplers("==>"__FUNCTION__": Sl: ", (_pDevice), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim)); \
373 }\
374 } while (0)
375
376#define VBOXVDBG_DUMP_DRAWPRIM_LEAVE(_pDevice) do { \
377 BOOL fDumpShaded = FALSE; \
378 VBOXVDBG_IS_DUMP_SHARED_ALLOWED_DEV(_pDevice, &fDumpShaded); \
379 if (fDumpShaded \
380 || VBOXVDBG_IS_DUMP_ALLOWED(DrawPrim)) \
381 { \
382 vboxVDbgDoDumpRt("<=="__FUNCTION__": Rt: ", (_pDevice), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim)); \
383 vboxVDbgDoDumpSamplers("<=="__FUNCTION__": Sl: ", (_pDevice), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim)); \
384 }\
385 } while (0)
386
387#define VBOXVDBG_BREAK_SHARED_DEV(_pDevice) do { \
388 BOOL fBreakShaded = FALSE; \
389 VBOXVDBG_IS_BREAK_SHARED_ALLOWED_DEV(_pDevice, &fBreakShaded); \
390 if (fBreakShaded) { \
391 vboxVDbgPrint((__FUNCTION__"== Break on shared access\n")); \
392 AssertFailed(); \
393 } \
394 } while (0)
395
396#define VBOXVDBG_DUMP_SETTEXTURE(_pRc) do { \
397 if (VBOXVDBG_IS_DUMP_ALLOWED(SetTexture) \
398 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pRc) \
399 ) \
400 { \
401 vboxVDbgDoDumpRcRect("== "__FUNCTION__": ", &(_pRc)->aAllocations[0], NULL, NULL, "", \
402 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(SetTexture) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
403 } \
404 } while (0)
405
406#define VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { \
407 if (VBOXVDBG_IS_DUMP_ALLOWED(TexBlt) \
408 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pSrcRc) \
409 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pDstRc) \
410 ) \
411 { \
412 RECT SrcRect = *(_pSrcRect); \
413 RECT _DstRect; \
414 vboxWddmRectMoved(&_DstRect, &SrcRect, (_pDstPoint)->x, (_pDstPoint)->y); \
415 vboxVDbgDoDumpRcRect("==> "__FUNCTION__": Src: ", &(_pSrcRc)->aAllocations[0], NULL, &SrcRect, "", \
416 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(TexBlt) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
417 vboxVDbgDoDumpRcRect("==> "__FUNCTION__": Dst: ", &(_pDstRc)->aAllocations[0], NULL, &_DstRect, "", \
418 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(TexBlt) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
419 } \
420 } while (0)
421
422#define VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { \
423 if (VBOXVDBG_DUMP_RECTS_FORCED() \
424 || VBOXVDBG_IS_DUMP_ALLOWED(TexBlt) \
425 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pSrcRc) \
426 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED(_pDstRc) \
427 ) \
428 { \
429 RECT SrcRect = *(_pSrcRect); \
430 RECT _DstRect; \
431 vboxWddmRectMoved(&_DstRect, &SrcRect, (_pDstPoint)->x, (_pDstPoint)->y); \
432 vboxVDbgDoDumpRcRect("<== "__FUNCTION__": Src: ", &(_pSrcRc)->aAllocations[0], NULL, &SrcRect, "", \
433 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(TexBlt) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
434 vboxVDbgDoDumpRcRect("<== "__FUNCTION__": Dst: ", &(_pDstRc)->aAllocations[0], NULL, &_DstRect, "", \
435 VBOXVDBG_DUMP_FLAGS_FOR_TYPE(TexBlt) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared)); \
436 } \
437 } while (0)
438
439#define VBOXVDBG_DUMP_STRETCH_RECT(_type, _str, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { \
440 if (VBOXVDBG_IS_DUMP_ALLOWED(_type) \
441 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED((_pSrcAlloc)->pRc) \
442 || VBOXVDBG_IS_DUMP_SHARED_ALLOWED((_pDstAlloc)->pRc) \
443 ) \
444 { \
445 DWORD fFlags = VBOXVDBG_DUMP_FLAGS_FOR_TYPE(_type) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Shared); \
446 if (VBOXVDBG_DUMP_TYPE_CONTENTS(fFlags) && \
447 ((_pSrcSurf) == (_pDstSurf) \
448 && ( ((_pSrcRect) && (_pDstRect) && !memcmp((_pSrcRect), (_pDstRect), sizeof (_pDstRect))) \
449 || ((_pSrcRect) == (_pDstRect)) \
450 )) ) \
451 { \
452 vboxVDbgPrint((_str #_type ": skipping content dump of the same rect for one surfcace\n")); \
453 fFlags = VBOXVDBG_DUMP_TYPE_GET_FLOW_ONLY(fFlags); \
454 } \
455 RECT Rect, *pRect; \
456 if (_pSrcRect) \
457 { \
458 Rect = *((RECT*)(_pSrcRect)); \
459 pRect = &Rect; \
460 } \
461 else \
462 pRect = NULL; \
463 vboxVDbgDoDumpRcRect(_str __FUNCTION__" Src: ", (_pSrcAlloc), (_pSrcSurf), pRect, "", fFlags); \
464 if (_pDstRect) \
465 { \
466 Rect = *((RECT*)(_pDstRect)); \
467 pRect = &Rect; \
468 } \
469 else \
470 pRect = NULL; \
471 vboxVDbgDoDumpRcRect(_str __FUNCTION__" Dst: ", (_pDstAlloc), (_pDstSurf), pRect, "", fFlags); \
472 } \
473 } while (0)
474
475#define VBOXVDBG_DUMP_BLT_ENTER(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
476 VBOXVDBG_DUMP_STRETCH_RECT(Blt, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
477
478#define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
479 VBOXVDBG_DUMP_STRETCH_RECT(Blt, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
480
481#define VBOXVDBG_IS_SKIP_DWM_WND_UPDATE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) ( \
482 g_VBoxVDbgFSkipCheckTexBltDwmWndUpdate \
483 && ( \
484 VBOXVDBG_IS_DWM() \
485 && (_pSrcRc)->RcDesc.enmPool == D3DDDIPOOL_SYSTEMMEM \
486 && (_pSrcRc)->RcDesc.enmFormat == D3DDDIFMT_A8R8G8B8 \
487 && (_pSrcRc)->cAllocations == 1 \
488 && (_pDstRc)->RcDesc.enmPool == D3DDDIPOOL_VIDEOMEMORY \
489 && (_pDstRc)->RcDesc.enmFormat == D3DDDIFMT_A8R8G8B8 \
490 && (_pDstRc)->RcDesc.fFlags.RenderTarget \
491 && (_pDstRc)->RcDesc.fFlags.NotLockable \
492 && (_pDstRc)->cAllocations == 1 \
493 && (_pSrcRc)->aAllocations[0].SurfDesc.width == (_pDstRc)->aAllocations[0].SurfDesc.width \
494 && (_pSrcRc)->aAllocations[0].SurfDesc.height == (_pDstRc)->aAllocations[0].SurfDesc.height \
495 ) \
496 )
497
498#define VBOXVDBG_CHECK_TEXBLT(_opTexBlt, _pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { \
499 if (VBOXVDBG_IS_CHECK_ALLOWED(TexBlt)) { \
500 if (VBOXVDBG_IS_SKIP_DWM_WND_UPDATE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint)) \
501 { \
502 vboxVDbgPrint(("TEXBLT: skipping check for dwm wnd update\n")); \
503 } \
504 else \
505 { \
506 RECT DstRect; \
507 DstRect.left = (_pDstPoint)->x; \
508 DstRect.right = (_pDstPoint)->x + (_pSrcRect)->right - (_pSrcRect)->left; \
509 DstRect.top = (_pDstPoint)->y; \
510 DstRect.bottom = (_pDstPoint)->y + (_pSrcRect)->bottom - (_pSrcRect)->top; \
511 VBOXVDBG_CHECK_RECTS(\
512 VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint); \
513 _opTexBlt ,\
514 VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint), \
515 "TexBlt", \
516 _pDstRc, 0, _pSrcRc, 0, &DstRect, _pSrcRect); \
517 break; \
518 } \
519 } \
520 VBOXVDBG_DUMP_RECTS_INIT(0); \
521 VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint); \
522 _opTexBlt;\
523 VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint); \
524 } while (0)
525
526#define VBOXVDBG_CHECK_STRETCH_RECT(_type, _op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { \
527 if (VBOXVDBG_IS_CHECK_ALLOWED(_type)) { \
528 VBOXVDBG_CHECK_RECTS(\
529 VBOXVDBG_DUMP_STRETCH_RECT(_type, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect); \
530 _op ,\
531 VBOXVDBG_DUMP_STRETCH_RECT(_type, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect), \
532 #_type , \
533 _pDstAlloc->pRc, _pDstAlloc->iAlloc, _pSrcAlloc->pRc, _pSrcAlloc->iAlloc, _pDstRect, _pSrcRect); \
534 } \
535 else \
536 { \
537 VBOXVDBG_DUMP_RECTS_INIT(0); \
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 } \
542 } while (0)
543
544#define VBOXVDBG_CHECK_BLT(_opBlt, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
545 VBOXVDBG_CHECK_STRETCH_RECT(Blt, _opBlt, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
546
547#define VBOXVDBG_DUMP_SYNC_RT(_pBbSurf) do { \
548 if (VBOXVDBG_IS_DUMP_ALLOWED(RtSynch)) \
549 { \
550 vboxVDbgDoDumpRcRect("== "__FUNCTION__" Bb:\n", NULL, (_pBbSurf), NULL, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(RtSynch)); \
551 } \
552 } while (0)
553
554
555#define VBOXVDBG_DUMP_FLUSH(_pDevice) do { \
556 if (VBOXVDBG_IS_DUMP_ALLOWED(Flush)) \
557 { \
558 vboxVDbgDoDumpRt("== "__FUNCTION__": Rt: ", (_pDevice), "", \
559 VBOXVDBG_DUMP_FLAGS_CLEAR(VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Flush), VBOXVDBG_DUMP_TYPEF_SHARED_ONLY)); \
560 }\
561 } while (0)
562
563#define VBOXVDBG_DUMP_LOCK_ST(_pData) do { \
564 if (VBOXVDBG_IS_DUMP_ALLOWED(Lock) \
565 || VBOXVDBG_IS_DUMP_ALLOWED(Unlock) \
566 ) \
567 { \
568 vboxVDbgDoDumpLockSurfTex("== "__FUNCTION__": ", (_pData), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Lock)); \
569 } \
570 } while (0)
571
572#define VBOXVDBG_DUMP_UNLOCK_ST(_pData) do { \
573 if (VBOXVDBG_IS_DUMP_ALLOWED(Unlock) \
574 ) \
575 { \
576 vboxVDbgDoDumpUnlockSurfTex("== "__FUNCTION__": ", (_pData), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Unlock)); \
577 } \
578 } while (0)
579
580#else
581#define VBOXVDBG_DUMP_DRAWPRIM_ENTER(_pDevice) do { } while (0)
582#define VBOXVDBG_DUMP_DRAWPRIM_LEAVE(_pDevice) do { } while (0)
583#define VBOXVDBG_DUMP_SETTEXTURE(_pRc) do { } while (0)
584#define VBOXVDBG_DUMP_TEXBLT_ENTER(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { } while (0)
585#define VBOXVDBG_DUMP_TEXBLT_LEAVE(_pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { } while (0)
586#define VBOXVDBG_DUMP_BLT_ENTER(_pSrcRc, _pSrcSurf, _pSrcRect, _pDstRc, _pDstSurf, _pDstRect) do { } while (0)
587#define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcRc, _pSrcSurf, _pSrcRect, _pDstRc, _pDstSurf, _pDstRect) do { } while (0)
588#define VBOXVDBG_DUMP_SYNC_RT(_pBbSurf) do { } while (0)
589#define VBOXVDBG_DUMP_FLUSH(_pDevice) do { } while (0)
590#define VBOXVDBG_DUMP_LOCK_ST(_pData) do { } while (0)
591#define VBOXVDBG_DUMP_UNLOCK_ST(_pData) do { } while (0)
592#define VBOXVDBG_BREAK_SHARED(_pRc) do { } while (0)
593#define VBOXVDBG_BREAK_SHARED_DEV(_pDevice) do { } while (0)
594#define VBOXVDBG_BREAK_DDI() do { } while (0)
595#define VBOXVDBG_CHECK_SMSYNC(_pRc) do { } while (0)
596#define VBOXVDBG_CHECK_BLT(_opBlt, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { _opBlt; } while (0)
597#define VBOXVDBG_CHECK_TEXBLT(_opTexBlt, _pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { _opTexBlt; } while (0)
598#define VBOXVDBG_ASSERT_IS_DWM(_bDwm) do { } while (0)
599#endif
600
601
602#endif /* !GA_INCLUDED_SRC_WINNT_Graphics_Video_disp_wddm_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