VBoxDispDbg.cpp revision a4185aaf392f086da0fd30f6157d047a72f2e35b
/* $Id$ */
/** @file
* VBoxVideo Display D3D User mode dll
*/
/*
* Copyright (C) 2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
/* @todo: move this to VBoxDispD3DCmn.h ? */
# include <windows.h>
# pragma warning(default : 4163)
# else
# include <windows.h>
# endif
#include "VBoxDispD3DCmn.h"
#include <stdio.h>
#include <stdarg.h>
#ifdef VBOXWDDMDISP_DEBUG
#define VBOXWDDMDISP_DEBUG_DUMP_DEFAULT 0
DWORD g_VBoxVDbgFBreakDdi = 0;
DWORD g_VBoxVDbgFCheckBlt = 0;
DWORD g_VBoxVDbgFLogFlow = 0;
char g_VBoxVDbgModuleName[MAX_PATH];
DWORD g_VBoxVDbgPid = 0;
typedef enum
{
typedef struct VBOXDISPDBG
{
} VBOXDISPDBG, *PVBOXDISPDBG;
static VBOXDISPDBG g_VBoxDispDbg = {0};
{
if (ASMAtomicCmpXchgU32((volatile uint32_t *)&g_VBoxDispDbg.enmState, VBOXDISPDBG_STATE_INITIALIZING, VBOXDISPDBG_STATE_UNINITIALIZED))
{
{
return &g_VBoxDispDbg;
}
else
{
}
}
else if (ASMAtomicReadU32((volatile uint32_t *)&g_VBoxDispDbg.enmState) == VBOXDISPDBG_STATE_INITIALIZED)
{
return &g_VBoxDispDbg;
}
Assert(0);
return NULL;
}
void vboxDispLogDrv(char * szString)
{
if (!pDbg)
{
/* do not use WARN her esince this would lead to a recursion */
WARN_BREAK();
return;
}
{
if (pCmd)
{
D3DKMT_ESCAPE EscapeData = {0};
//EscapeData.hDevice = NULL;
// EscapeData.Flags.HardwareAccess = 1;
//EscapeData.hContext = NULL;
if (Status)
{
WARN_BREAK();
}
}
else
{
WARN_BREAK();
}
{
WARN_BREAK();
}
}
}
void vboxDispLogDrvF(char * szString, ...)
{
char szBuffer[4096] = {0};
}
void vboxDispLogDbgPrintF(char * szString, ...)
{
char szBuffer[4096] = {0};
}
VOID vboxVDbgDoDumpSurfRectByAlloc(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, const RECT *pRect, const char* pSuffix)
{
}
{
}
VOID vboxVDbgDoPrintDumpCmd(const char* pszDesc, const void *pvData, uint32_t width, uint32_t height, uint32_t bpp, uint32_t pitch)
{
char Cmd[1024];
}
{
}
VOID vboxVDbgDoDumpAllocRect(const char * pPrefix, PVBOXWDDMDISP_ALLOCATION pAlloc, const RECT *pRect, const char* pSuffix)
{
if (pPrefix)
{
}
{
vboxVDbgDoPrintDumpCmd("Surf Info", LockData.pData, pAlloc->D3DWidth, pAlloc->SurfDesc.height, bpp, pAlloc->SurfDesc.pitch);
if (pRect)
{
vboxVDbgDoPrintDumpCmd("Rect Info", ((uint8_t*)LockData.pData) + (pRect->top * pAlloc->SurfDesc.pitch) + ((pRect->left * bpp) >> 3),
}
Assert(0);
}
if (pSuffix)
{
}
}
VOID vboxVDbgDoDumpSurfRectByRc(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const RECT *pRect, const char* pSuffix)
{
BOOL bReleaseSurf = false;
{
}
}
VOID vboxVDbgDoDumpSurfRect(const char * pPrefix, IDirect3DSurface9 *pSurf, const RECT *pRect, const char * pSuffix, bool bBreak)
{
if (pPrefix)
{
}
{
{
if (pRect)
{
vboxVDbgDoPrintDumpCmd("Rect Info", ((uint8_t*)Lr.pBits) + (pRect->top * Lr.Pitch) + ((pRect->left * bpp) >> 3),
}
if (bBreak)
{
Assert(0);
}
}
}
if (pSuffix)
{
}
}
{
}
#define VBOXVDBG_STRCASE(_t) \
#define VBOXVDBG_STRCASE_UNKNOWN() \
default: Assert(0); return "Unknown";
{
switch (enmFace)
{
}
}
VOID vboxVDbgDoDumpRcRect(const char * pPrefix, IDirect3DResource9 *pRc, const RECT *pRect, const char * pSuffix)
{
if (pPrefix)
{
}
{
case D3DRTYPE_TEXTURE:
{
vboxVDbgPrint(("this is a texture\n"));
{
}
break;
}
case D3DRTYPE_CUBETEXTURE:
{
vboxVDbgPrint(("this is a cube texture\n"));
{
{
}
else
{
Assert(0);
}
}
Assert(0);
{
apSurf[i]->UnlockRect();
}
break;
}
case D3DRTYPE_SURFACE:
{
vboxVDbgPrint(("this is a surface\n"));
break;
}
default:
vboxVDbgPrint(("unsupported rc type\n"));
Assert(0);
}
if (pSuffix)
{
}
}
VOID vboxVDbgDoDumpRcRectByAlloc(const char * pPrefix, const PVBOXWDDMDISP_ALLOCATION pAlloc, IDirect3DResource9 *pD3DIf, const RECT *pRect, const char* pSuffix)
{
if (pPrefix)
if (!pD3DIf)
{
}
vboxVDbgPrint(("Rc(0x%p), pAlloc(0x%x), pD3DIf(0x%p), SharedHandle(0x%p)\n", pAlloc->pRc, pAlloc, pD3DIf, pAlloc->pRc->aAllocations[0].hSharedHandle));
}
VOID vboxVDbgDoDumpRcRectByRc(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, const RECT *pRect, const char* pSuffix)
{
}
{
}
{
{
{
// Assert(pAlloc->pD3DIf == pRt);
}
else
{
}
}
}
VOID vboxVDbgDoDumpLockUnlockSurfTex(const char * pPrefix, const PVBOXWDDMDISP_ALLOCATION pAlloc, const char * pSuffix, bool fBreak)
{
if (pPrefix)
{
}
void *pvData;
{
}
else
{
}
{
}
else
{
}
vboxVDbgPrint(("pRc(0x%p) iAlloc(%d), type(%d), cLocks(%d)\n", pAlloc->pRc, pAlloc->iAlloc, pAlloc->enmD3DIfType, pAlloc->LockInfo.cLocks));
if (fBreak)
{
Assert(0);
}
if (pSuffix)
{
}
}
VOID vboxVDbgDoDumpLockSurfTex(const char * pPrefix, const D3DDDIARG_LOCK* pData, const char * pSuffix, bool fBreak)
{
}
VOID vboxVDbgDoDumpUnlockSurfTex(const char * pPrefix, const D3DDDIARG_UNLOCK* pData, const char * pSuffix, bool fBreak)
{
}
BOOL vboxVDbgDoCheckLRects(D3DLOCKED_RECT *pDstLRect, const RECT *pDstRect, D3DLOCKED_RECT *pSrcLRect, const RECT *pSrcRect, DWORD bpp, BOOL fBreakOnMismatch)
{
{
WARN(("stretched comparison not supported!!"));
return FALSE;
}
{
{
vboxVDbgPrint(("not match!\n"));
if (fBreakOnMismatch)
Assert(0);
break;
}
}
return fMatch;
}
#ifndef IN_VBOXCRHGSMI
{
if (!pDstRect)
{
}
if (!pSrcRect)
{
}
{
{
vboxVDbgPrint(("matching same rect of one allocation, skipping..\n"));
return TRUE;
}
WARN(("matching different rects of the same allocation, unsupported!"));
return FALSE;
}
{
WARN(("matching different formats, unsupported!"));
return FALSE;
}
if (!bpp)
{
WARN(("uninited bpp! unsupported!"));
return FALSE;
}
{
WARN(("stretched comparison not supported!!"));
return FALSE;
}
{
return FALSE;
}
{
return FALSE;
}
return fMatch;
}
#endif
void vboxVDbgDoPrintAlloc(const char * pPrefix, const PVBOXWDDMDISP_RESOURCE pRc, uint32_t iAlloc, const char * pSuffix)
{
if (bPrimary)
{
}
bPrimary ?
: "?Everage? Alloc",
pSuffix));
}
{
vboxVDbgPrint(("%s left(%d), top(%d), right(%d), bottom(%d) %s", pPrefix, pRect->left, pRect->top, pRect->right, pRect->bottom, pSuffix));
}
char *vboxVDbgDoGetModuleName()
{
{
if (!cName)
{
return NULL;
}
}
return g_VBoxVDbgModuleName;
}
{
char *pszModule = vboxVDbgDoGetModuleName();
if (!pszModule)
return FALSE;
return FALSE;
return FALSE;
return TRUE;
}
#endif
#ifdef VBOXWDDMDISP_DEBUG_VEHANDLER
{
switch (pExceptionRecord->ExceptionCode)
{
case EXCEPTION_BREAKPOINT:
case EXCEPTION_STACK_OVERFLOW:
AssertRelease(0);
break;
default:
break;
}
return EXCEPTION_CONTINUE_SEARCH;
}
void vboxVDbgVEHandlerRegister()
{
}
void vboxVDbgVEHandlerUnregister()
{
}
#endif