VBoxDispDbg.h revision 7de21438395845af0147c375a00fed8f172354f6
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync * VBoxVideo Display D3D User mode dll
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync * Copyright (C) 2011 Oracle Corporation
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync * available from http://www.virtualbox.org. This file is free software;
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync * you can redistribute it and/or modify it under the terms of the GNU
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync * General Public License (GPL) as published by the Free Software
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0d0253c4c63a28f67509d37a41df855173e94ee1vboxsync#define VBOX_VIDEO_LOG_LOGGER vboxVDbgInternalLogLogger
7d913420297c8662dd9523fbf927125b3ed48814vboxsync#define VBOX_VIDEO_LOGREL_LOGGER vboxVDbgInternalLogRelLogger
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync#define VBOX_VIDEO_LOGFLOW_LOGGER vboxVDbgInternalLogFlowLogger
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync#include "../../common/VBoxVideoLog.h"
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync/* debugging configuration flags */
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync/* generic debugging facilities & extra data checks */
7d913420297c8662dd9523fbf927125b3ed48814vboxsync/* for some reason when debugging with VirtualKD, user-mode DbgPrint's are discarded
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync * the workaround so far is to pass the log info to the kernel driver and DbgPrint'ed from there,
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync * which is enabled by this define */
0d0253c4c63a28f67509d37a41df855173e94ee1vboxsync//# define VBOXWDDMDISP_DEBUG_PRINTDRV
0d0253c4c63a28f67509d37a41df855173e94ee1vboxsync/* use OutputDebugString */
0d0253c4c63a28f67509d37a41df855173e94ee1vboxsync//# define VBOXWDDMDISP_DEBUG_PRINT
0d0253c4c63a28f67509d37a41df855173e94ee1vboxsync/* adds vectored exception handler to be able to catch non-debug UM exceptions in kernel debugger */
0d0253c4c63a28f67509d37a41df855173e94ee1vboxsync//# define VBOXWDDMDISP_DEBUG_VEHANDLER
8532fcd8b260a1648f09ab3df65e5353aa148825vboxsync/* disable shared resource creation with wine */
0d0253c4c63a28f67509d37a41df855173e94ee1vboxsync//# define VBOXWDDMDISP_DEBUG_NOSHARED
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync/* debug config vars */
0d0253c4c63a28f67509d37a41df855173e94ee1vboxsyncextern DWORD g_VBoxVDbgFSkipCheckTexBltDwmWndUpdate;
1cee507a10df8208ebb4a36db7073b312dff343fvboxsync/* log enable flags */
2c7402dd06f73977076fdbc86bb9f1c0c2be17f9vboxsyncextern struct VBOXWDDMDISP_DEVICE *g_VBoxVDbgInternalDevice;
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsyncextern struct VBOXWDDMDISP_RESOURCE *g_VBoxVDbgInternalRc;
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync# define AssertBreakpoint() do{}while(0)
0d0253c4c63a28f67509d37a41df855173e94ee1vboxsync# define AssertFailed() do{}while(0)
0d0253c4c63a28f67509d37a41df855173e94ee1vboxsync#if defined(LOG_TO_BACKDOOR_DRV) || defined(VBOXWDDMDISP_DEBUG_PRINTDRV)
0d0253c4c63a28f67509d37a41df855173e94ee1vboxsync# define DbgPrintDrv(_m) do { vboxDispLogDrvF _m; } while (0)
0d0253c4c63a28f67509d37a41df855173e94ee1vboxsync# define DbgPrintDrvRel(_m) do { vboxDispLogDrvF _m; } while (0)
0d0253c4c63a28f67509d37a41df855173e94ee1vboxsync# define DbgPrintDrvFlow(_m) do { vboxDispLogDrvF _m; } while (0)
a7d389fbff436fb217a78d48fab17adcaf43dc54vboxsync# define DbgPrintUsr(_m) do { vboxDispLogDbgPrintF _m; } while (0)
8532fcd8b260a1648f09ab3df65e5353aa148825vboxsync# define DbgPrintUsrRel(_m) do { vboxDispLogDbgPrintF _m; } while (0)
8532fcd8b260a1648f09ab3df65e5353aa148825vboxsync# define DbgPrintUsrFlow(_m) do { vboxDispLogDbgPrintF _m; } while (0)
7d913420297c8662dd9523fbf927125b3ed48814vboxsync#define vboxVDbgInternalLog(_p) if (g_VBoxVDbgFLog) { _p }
7d913420297c8662dd9523fbf927125b3ed48814vboxsync#define vboxVDbgInternalLogFlow(_p) if (g_VBoxVDbgFLogFlow) { _p }
7d913420297c8662dd9523fbf927125b3ed48814vboxsync#define vboxVDbgInternalLogRel(_p) if (g_VBoxVDbgFLogRel) { _p }
7d913420297c8662dd9523fbf927125b3ed48814vboxsync#define vboxVDbgInternalLogRel(_p) do { _p } while (0)
7d913420297c8662dd9523fbf927125b3ed48814vboxsync/* @todo: remove these from the code and from here */
7d913420297c8662dd9523fbf927125b3ed48814vboxsync } while (0)
7d913420297c8662dd9523fbf927125b3ed48814vboxsync } while (0)
1cee507a10df8208ebb4a36db7073b312dff343fvboxsync } while (0)
7d913420297c8662dd9523fbf927125b3ed48814vboxsync#if defined(VBOXWDDMDISP_DEBUG) || defined(LOG_TO_BACKDOOR_DRV)
switch (enmType)
#include "VBoxDispMpLogger.h"
#ifdef VBOXWDDMDISP_DEBUG
#define VBOXVDBG_DUMP_TYPE_ENABLED(_fFlags) (VBOXVDBG_DUMP_FLAGS_IS_SETANY(_fFlags, VBOXVDBG_DUMP_TYPEF_FLOW | VBOXVDBG_DUMP_TYPEF_CONTENTS))
#define VBOXVDBG_DUMP_TYPE_FLOW_ONLY(_fFlags) (VBOXVDBG_DUMP_FLAGS_IS_SET(_fFlags, VBOXVDBG_DUMP_TYPEF_FLOW) \
#define VBOXVDBG_DUMP_TYPE_CONTENTS(_fFlags) (VBOXVDBG_DUMP_FLAGS_IS_SET(_fFlags, VBOXVDBG_DUMP_TYPEF_CONTENTS))
VOID vboxVDbgDoDumpAllocRect(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, RECT *pRect, const char* pSuffix, DWORD fFlags);
VOID vboxVDbgDoDumpRcRect(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DResource9 *pD3DRc, RECT *pRect, const char * pSuffix, DWORD fFlags);
VOID vboxVDbgDoDumpLockUnlockSurfTex(const char * pPrefix, const PVBOXWDDMDISP_ALLOCATION pAlloc, const char * pSuffix, DWORD fFlags);
VOID vboxVDbgDoDumpRt(const char * pPrefix, struct VBOXWDDMDISP_DEVICE *pDevice, const char * pSuffix, DWORD fFlags);
VOID vboxVDbgDoDumpBb(const char * pPrefix, IDirect3DSwapChain9 *pSwapchainIf, const char * pSuffix, DWORD fFlags);
VOID vboxVDbgDoDumpFb(const char * pPrefix, IDirect3DSwapChain9 *pSwapchainIf, const char * pSuffix, DWORD fFlags);
VOID vboxVDbgDoDumpSamplers(const char * pPrefix, struct VBOXWDDMDISP_DEVICE *pDevice, const char * pSuffix, DWORD fFlags);
void vboxVDbgDoPrintAlloc(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const char * pSuffix);
VOID vboxVDbgDoDumpLockSurfTex(const char * pPrefix, const D3DDDIARG_LOCK* pData, const char * pSuffix, DWORD fFlags);
VOID vboxVDbgDoDumpUnlockSurfTex(const char * pPrefix, const D3DDDIARG_UNLOCK* pData, const char * pSuffix, DWORD fFlags);
#define VBOXVDBG_IS_PID(_pid) ((_pid) == (g_VBoxVDbgPid ? g_VBoxVDbgPid : (g_VBoxVDbgPid = GetCurrentProcessId())))
#define VBOXVDBG_IS_DUMP_ALLOWED_PID(_pid) (((int)(_pid)) > 0 ? VBOXVDBG_IS_PID(_pid) : !VBOXVDBG_IS_PID(-((int)(_pid))))
#define VBOXVDBG_IS_DWM() (!!(g_VBoxVDbgFIsDwm >=0 ? g_VBoxVDbgFIsDwm : (g_VBoxVDbgFIsDwm = VBOXVDBG_CHECK_EXE("dwm.exe"))))
#define VBOXVDBG_IS_DUMP_ALLOWED(_type) ( VBOXVDBG_DUMP_TYPE_ENABLED(VBOXVDBG_DUMP_FLAGS_FOR_TYPE(_type)) )
vboxVDbgPrint(("Break on shared access: Rc(0x%p), SharedHandle(0x%p)\n", (_pRc), (_pRc)->aAllocations[0].hSharedHandle)); \
AssertFailed(); \
#define VBOXVDBG_BREAK_DDI() do { \
AssertFailed(); \
_op; \
} while (vboxVDbgLoop); \
#define VBOXVDBG_CHECK_RECTS(_opRests, _opDump, _pszOpName, _pDstRc, _iDstAlloc, _pSrcRc, _iSrcAlloc, _pDstRect, _pSrcRect) do { \
VBOXVDBG_DUMP_RECTS_INIT(0); \
_opRests; \
if (vboxVDbgDoCheckRectsMatch(_pDstRc, _iDstAlloc, _pSrcRc, _iSrcAlloc, _pDstRect, _pSrcRect, FALSE)) { \
VBOXVDBG_LOOP_LAST(); \
vboxVDbgPrint(("vboxVDbgDoCheckRectsMatch failed! The " _pszOpName " will be re-done so it can be debugged\n")); \
Assert(0); \
_opDump; \
if (!*(_pIsShared)) { \
++iSampler; \
if (*(_pIsAllowed)) \
if (*(_pIsAllowed)) \
if (fDumpShaded \
vboxVDbgDoDumpRt("==>"__FUNCTION__": Rt: ", (_pDevice), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Flush) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim)); \
vboxVDbgDoDumpSamplers("==>"__FUNCTION__": Sl: ", (_pDevice), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Flush) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim)); \
if (fDumpShaded \
vboxVDbgDoDumpSamplers("<=="__FUNCTION__": Sl: ", (_pDevice), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Flush) | VBOXVDBG_DUMP_FLAGS_FOR_TYPE(DrawPrim)); \
if (fBreakShaded) { \
AssertFailed(); \
vboxVDbgDoDumpRcRect("==> "__FUNCTION__": Src: ", &(_pSrcRc)->aAllocations[0], NULL, &SrcRect, "", \
vboxVDbgDoDumpRcRect("==> "__FUNCTION__": Dst: ", &(_pDstRc)->aAllocations[0], NULL, &_DstRect, "", \
if (VBOXVDBG_DUMP_RECTS_FORCED() \
vboxVDbgDoDumpRcRect("<== "__FUNCTION__": Src: ", &(_pSrcRc)->aAllocations[0], NULL, &SrcRect, "", \
vboxVDbgDoDumpRcRect("<== "__FUNCTION__": Dst: ", &(_pDstRc)->aAllocations[0], NULL, &_DstRect, "", \
#define VBOXVDBG_DUMP_STRETCH_RECT(_type, _str, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { \
if (_pSrcRect) \
if (_pDstRect) \
#define VBOXVDBG_DUMP_BLT_ENTER(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
VBOXVDBG_DUMP_STRETCH_RECT(Blt, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
#define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
VBOXVDBG_DUMP_STRETCH_RECT(Blt, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
#define VBOXVDBG_DUMP_SWAPCHAIN_SYNC_ENTER(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
VBOXVDBG_DUMP_STRETCH_RECT(ScSync, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
#define VBOXVDBG_DUMP_SWAPCHAIN_SYNC_LEAVE(_pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
VBOXVDBG_DUMP_STRETCH_RECT(ScSync, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
VBOXVDBG_IS_DWM() \
_opTexBlt ,\
VBOXVDBG_DUMP_RECTS_INIT(0); \
#define VBOXVDBG_CHECK_STRETCH_RECT(_type, _op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { \
VBOXVDBG_DUMP_STRETCH_RECT(_type, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect); \
_op ,\
VBOXVDBG_DUMP_STRETCH_RECT(_type, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect), \
#_type , \
VBOXVDBG_DUMP_RECTS_INIT(0); \
VBOXVDBG_DUMP_STRETCH_RECT(_type, "==>", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect); \
_op;\
VBOXVDBG_DUMP_STRETCH_RECT(_type, "<==", _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect); \
#define VBOXVDBG_CHECK_BLT(_opBlt, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
VBOXVDBG_CHECK_STRETCH_RECT(Blt, _opBlt, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
#define VBOXVDBG_CHECK_SWAPCHAIN_SYNC(_op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) \
VBOXVDBG_CHECK_STRETCH_RECT(ScSync, _op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect)
vboxVDbgDoDumpRcRect("== "__FUNCTION__" Bb:\n", NULL, (_pBbSurf), NULL, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(RtSynch)); \
vboxVDbgDoDumpBb("==>"__FUNCTION__" Bb:\n", (_pSwapchain)->pSwapChainIf, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(PresentEnter)); \
vboxVDbgDoDumpRcRect("== "__FUNCTION__" Bb:\n", pCurBb, pSurf, NULL, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(PresentEnter)); \
vboxVDbgDoDumpFb("<=="__FUNCTION__" Fb:\n", (_pSwapchain)->pSwapChainIf, "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(PresentLeave)); \
vboxVDbgDoDumpLockSurfTex("== "__FUNCTION__": ", (_pData), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Lock)); \
vboxVDbgDoDumpUnlockSurfTex("== "__FUNCTION__": ", (_pData), "", VBOXVDBG_DUMP_FLAGS_FOR_TYPE(Unlock)); \
#define VBOXVDBG_CREATE_CHECK_SWAPCHAIN() do { \
HRESULT hr = vboxWddmSwapchainCreateIfForRc(g_VBoxVDbgInternalDevice, g_VBoxVDbgInternalRc, &pSwapchain); \
#define VBOXVDBG_DUMP_BLT_ENTER(_pSrcRc, _pSrcSurf, _pSrcRect, _pDstRc, _pDstSurf, _pDstRect) do { } while (0)
#define VBOXVDBG_DUMP_BLT_LEAVE(_pSrcRc, _pSrcSurf, _pSrcRect, _pDstRc, _pDstSurf, _pDstRect) do { } while (0)
#define VBOXVDBG_BREAK_DDI() do { } while (0)
#define VBOXVDBG_CHECK_BLT(_opBlt, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { _opBlt; } while (0)
#define VBOXVDBG_CHECK_TEXBLT(_opTexBlt, _pSrcRc, _pSrcRect, _pDstRc, _pDstPoint) do { _opTexBlt; } while (0)
#define VBOXVDBG_CHECK_SWAPCHAIN_SYNC(_op, _pSrcAlloc, _pSrcSurf, _pSrcRect, _pDstAlloc, _pDstSurf, _pDstRect) do { _op; } while (0)
#define VBOXVDBG_CREATE_CHECK_SWAPCHAIN() do { } while (0)