DbgConsole vertex buffer enable/disable
This commit is contained in:
parent
607fc31812
commit
7b6f156f59
|
@ -55,13 +55,13 @@ typedef signed short sint16;
|
|||
typedef signed long sint32;
|
||||
|
||||
// define this to track vertex buffers for debugging purposes
|
||||
#define _DEBUG_TRACK_VB
|
||||
//#define _DEBUG_TRACK_VB
|
||||
|
||||
// define this to trace intercepted function calls
|
||||
#define _DEBUG_TRACE
|
||||
//#define _DEBUG_TRACE
|
||||
|
||||
// define this to trace warnings
|
||||
#define _DEBUG_WARNINGS
|
||||
//#define _DEBUG_WARNINGS
|
||||
|
||||
// version information
|
||||
#ifndef _DEBUG_TRACE
|
||||
|
|
|
@ -44,6 +44,8 @@ struct VBNode
|
|||
VBNode *next;
|
||||
};
|
||||
|
||||
extern bool g_bVBSkipStream;
|
||||
|
||||
extern class VBTracker
|
||||
{
|
||||
public:
|
||||
|
@ -59,6 +61,9 @@ extern class VBTracker
|
|||
// check for existance of ptr
|
||||
bool exists(XTL::IDirect3DVertexBuffer8 *pVB);
|
||||
|
||||
// for traversal
|
||||
VBNode *getHead() { return m_head; }
|
||||
|
||||
private:
|
||||
// list of "live" vertex buffers for debugging purposes
|
||||
VBNode *m_head;
|
||||
|
|
|
@ -509,7 +509,7 @@ typedef PVOID (NTAPI *FPTR_RtlCreateHeap)
|
|||
IN PVOID Base OPTIONAL,
|
||||
IN ULONG Reserve OPTIONAL,
|
||||
IN ULONG Commit,
|
||||
IN BOOLEAN Lock OPTIONAL,
|
||||
IN PVOID Lock OPTIONAL,
|
||||
IN PVOID RtlHeapParams OPTIONAL
|
||||
);
|
||||
|
||||
|
|
|
@ -119,7 +119,7 @@ typedef PVOID (WINAPI *pfRtlCreateHeap)
|
|||
IN PVOID Base OPTIONAL,
|
||||
IN ULONG Reserve OPTIONAL,
|
||||
IN ULONG Commit,
|
||||
IN BOOLEAN Lock OPTIONAL,
|
||||
IN PVOID Lock OPTIONAL,
|
||||
IN PVOID RtlHeapParams OPTIONAL
|
||||
);
|
||||
|
||||
|
@ -289,7 +289,7 @@ PVOID WINAPI EmuRtlCreateHeap
|
|||
IN PVOID Base OPTIONAL,
|
||||
IN ULONG Reserve OPTIONAL,
|
||||
IN ULONG Commit,
|
||||
IN BOOLEAN Lock OPTIONAL,
|
||||
IN PVOID Lock OPTIONAL,
|
||||
IN PVOID RtlHeapParams OPTIONAL
|
||||
);
|
||||
|
||||
|
|
|
@ -114,13 +114,56 @@ void DbgConsole::Reset()
|
|||
m_szInput[0] = '\0';
|
||||
}
|
||||
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
static void EnableVB(int n, bool enable)
|
||||
{
|
||||
using namespace XTL;
|
||||
|
||||
int v=0;
|
||||
|
||||
VBNode *cur = g_VBTrackTotal.getHead();
|
||||
|
||||
for(v=0;v<n;v++)
|
||||
{
|
||||
if(cur == NULL || (cur->next == NULL))
|
||||
break;
|
||||
|
||||
cur = cur->next;
|
||||
}
|
||||
|
||||
if(n == v && (cur != NULL) && (cur->next != NULL))
|
||||
{
|
||||
if(enable)
|
||||
{
|
||||
g_VBTrackDisable.remove(cur->vb);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_VBTrackDisable.insert(cur->vb);
|
||||
}
|
||||
|
||||
printf("CxbxDbg: %.02d (0x%.08X) %s\n", n, cur->vb, enable ? "enabled" : "disabled");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("CxbxDbg: # out of range\n");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
void DbgConsole::ParseCommand()
|
||||
{
|
||||
printf("\n");
|
||||
|
||||
char szCmd[32];
|
||||
|
||||
sscanf(m_szInput, "%s", szCmd);
|
||||
|
||||
// TODO: as command list grows, turn into static string/ptr lookup
|
||||
|
||||
if(stricmp(m_szInput, "h") == 0 || stricmp(m_szInput, "help") == 0)
|
||||
if(stricmp(szCmd, "h") == 0 || stricmp(szCmd, "help") == 0)
|
||||
{
|
||||
printf("CxbxDbg: \n");
|
||||
printf("CxbxDbg: Cxbx Debug Command List:\n");
|
||||
|
@ -128,26 +171,94 @@ void DbgConsole::ParseCommand()
|
|||
printf("CxbxDbg: HELP (H)\n");
|
||||
printf("CxbxDbg: QUIT (Q or EXIT)\n");
|
||||
printf("CxbxDbg: TRACE (T)\n");
|
||||
printf("CxbxDbg: ListVB (LVB)\n");
|
||||
printf("CxbxDbg: DisableVB # (DVB #)\n");
|
||||
printf("CxbxDbg: EnableVB # (EVB #)\n");
|
||||
printf("CxbxDbg: CLS\n");
|
||||
printf("CxbxDbg: \n");
|
||||
}
|
||||
else if(stricmp(m_szInput, "cls") == 0)
|
||||
{
|
||||
// clear screen using system call
|
||||
system("cls");
|
||||
}
|
||||
else if(stricmp(m_szInput, "q") == 0 || stricmp(m_szInput, "quit") == 0 || stricmp(m_szInput, "exit") == 0)
|
||||
else if(stricmp(szCmd, "q") == 0 || stricmp(szCmd, "quit") == 0 || stricmp(szCmd, "exit") == 0)
|
||||
{
|
||||
printf("CxbxDbg: Goodbye...\n");
|
||||
EmuCleanup(NULL);
|
||||
}
|
||||
else if(stricmp(m_szInput, "t") == 0 || stricmp(m_szInput, "trace") == 0)
|
||||
else if(stricmp(szCmd, "t") == 0 || stricmp(szCmd, "trace") == 0)
|
||||
{
|
||||
g_bPrintfOn = !g_bPrintfOn;
|
||||
printf("CxbxDbg: Trace is now %s\n", g_bPrintfOn ? "ON" : "OFF");
|
||||
}
|
||||
else if(stricmp(szCmd, "lvb") == 0 || stricmp(szCmd, "ListVB") == 0)
|
||||
{
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
{
|
||||
using namespace XTL;
|
||||
|
||||
int v=0;
|
||||
|
||||
VBNode *cur = g_VBTrackTotal.getHead();
|
||||
|
||||
while(cur != NULL && cur->next != NULL)
|
||||
{
|
||||
bool enabled = !g_VBTrackDisable.exists(cur->vb);
|
||||
|
||||
printf("CxbxDbg: %.02d : 0x%.08X (%s)\n", v++, cur->vb, enabled ? "enabled" : "disabled");
|
||||
|
||||
cur = cur->next;
|
||||
}
|
||||
}
|
||||
#else
|
||||
printf("CxbxDbg: _DEBUG_TRACK_VB is not defined!\n");
|
||||
#endif
|
||||
}
|
||||
else if(stricmp(szCmd, "dvb") == 0 || stricmp(szCmd, "DisableVB") == 0)
|
||||
{
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
{
|
||||
using namespace XTL;
|
||||
|
||||
int n=0;
|
||||
|
||||
if(sscanf(m_szInput, "%*s %d", &n) == 1)
|
||||
{
|
||||
EnableVB(n, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("CxbxDbg: Cmd \"%s\" not recognized!\n", m_szInput);
|
||||
printf("CxbxDbg: Syntax Incorrect (dvb #)\n");
|
||||
}
|
||||
}
|
||||
#else
|
||||
printf("CxbxDbg: _DEBUG_TRACK_VB is not defined!\n");
|
||||
#endif
|
||||
}
|
||||
else if(stricmp(szCmd, "evb") == 0 || stricmp(szCmd, "EnableVB") == 0)
|
||||
{
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
{
|
||||
using namespace XTL;
|
||||
|
||||
int n=0;
|
||||
|
||||
if(sscanf(m_szInput, "%*s %d", &n) == 1)
|
||||
{
|
||||
EnableVB(n, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("CxbxDbg: Syntax Incorrect (dvb #)\n");
|
||||
}
|
||||
}
|
||||
#else
|
||||
printf("CxbxDbg: _DEBUG_TRACK_VB is not defined!\n");
|
||||
#endif
|
||||
}
|
||||
else if(stricmp(szCmd, "cls") == 0)
|
||||
{
|
||||
// clear screen using system call
|
||||
system("cls");
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("CxbxDbg: Cmd \"%s\" not recognized!\n", szCmd);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -665,7 +665,10 @@ extern "C" CXBXKRNL_API void NTAPI EmuCleanup(const char *szErrorMessage, ...)
|
|||
if(g_hEmuParent != NULL)
|
||||
SendMessage(g_hEmuParent, WM_PARENTNOTIFY, WM_DESTROY, 0);
|
||||
|
||||
TerminateProcess(GetCurrentProcess(), 0);
|
||||
exit(0);
|
||||
|
||||
// Much less friendly :]
|
||||
// TerminateProcess(GetCurrentProcess(), 0);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -3093,7 +3093,18 @@ static void EmuFlushD3DIVB()
|
|||
|
||||
g_pD3DDevice8->SetVertexShader(dwFVF);
|
||||
|
||||
HRESULT hRet = g_pD3DDevice8->DrawPrimitiveUP(XTL::EmuPrimitiveType(g_dwD3DIVBPrim), XTL::EmuD3DVertex2PrimitiveCount(g_dwD3DIVBPrim, g_dwD3DIVBInd), pStreamData, i/g_dwD3DIVBInd);
|
||||
HRESULT hRet = S_OK;
|
||||
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
if(!XTL::g_bVBSkipStream)
|
||||
{
|
||||
#endif
|
||||
|
||||
hRet = g_pD3DDevice8->DrawPrimitiveUP(XTL::EmuPrimitiveType(g_dwD3DIVBPrim), XTL::EmuD3DVertex2PrimitiveCount(g_dwD3DIVBPrim, g_dwD3DIVBInd), pStreamData, i/g_dwD3DIVBInd);
|
||||
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
}
|
||||
#endif
|
||||
|
||||
// HACK: TODO: probably unnecessary!!!
|
||||
//g_pD3DDevice8->Present(0,0,0,0);
|
||||
|
@ -3578,6 +3589,10 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register
|
|||
&pResource->EmuVertexBuffer8
|
||||
);
|
||||
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
g_VBTrackTotal.insert(pResource->EmuVertexBuffer8);
|
||||
#endif
|
||||
|
||||
BYTE *pData = 0;
|
||||
|
||||
hRet = pResource->EmuVertexBuffer8->Lock(0, 0, &pData, 0);
|
||||
|
@ -3780,6 +3795,7 @@ HRESULT WINAPI XTL::EmuIDirect3DResource8_Register
|
|||
EmuCleanup("CreateImageSurface Failed!");
|
||||
|
||||
DbgPrintf("EmuIDirect3DResource8_Register (0x%X) : Successfully Created ImageSurface (0x%.08X, 0x%.08X)\n", GetCurrentThreadId(), pResource, pResource->EmuSurface8);
|
||||
DbgPrintf("EmuIDirect3DResource8_Register (0x%X) : Width : %d, Height : %d, Format : %d\n", GetCurrentThreadId(), dwWidth, dwHeight, Format);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -4126,9 +4142,13 @@ VOID WINAPI XTL::EmuGet2DSurfaceDesc
|
|||
HRESULT hRet;
|
||||
|
||||
if(dwLevel == 0xFEFEFEFE)
|
||||
{
|
||||
hRet = pPixelContainer->EmuSurface8->GetDesc(&SurfaceDesc);
|
||||
}
|
||||
else
|
||||
{
|
||||
hRet = pPixelContainer->EmuTexture8->GetLevelDesc(dwLevel, &SurfaceDesc);
|
||||
}
|
||||
|
||||
// rearrange into windows format (remove D3DPOOL)
|
||||
{
|
||||
|
@ -4637,6 +4657,10 @@ XTL::X_D3DVertexBuffer* WINAPI XTL::EmuIDirect3DDevice8_CreateVertexBuffer2
|
|||
if(FAILED(hRet))
|
||||
EmuWarning("CreateVertexBuffer Failed!");
|
||||
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
g_VBTrackTotal.insert(pD3DVertexBuffer->EmuVertexBuffer8);
|
||||
#endif
|
||||
|
||||
EmuSwapFS(); // XBox FS
|
||||
|
||||
return pD3DVertexBuffer;
|
||||
|
@ -6057,6 +6081,13 @@ HRESULT WINAPI XTL::EmuIDirect3DDevice8_SetStreamSource
|
|||
pVertexBuffer8->Unlock();
|
||||
}
|
||||
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
if(pStreamData != NULL)
|
||||
{
|
||||
g_bVBSkipStream = g_VBTrackDisable.exists(pStreamData->EmuVertexBuffer8);
|
||||
}
|
||||
#endif
|
||||
|
||||
HRESULT hRet = g_pD3DDevice8->SetStreamSource(StreamNumber, pVertexBuffer8, Stride);
|
||||
|
||||
if(FAILED(hRet))
|
||||
|
@ -6151,6 +6182,11 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_DrawVertices
|
|||
|
||||
uint32 nStride = EmuFixupVerticesA(PrimitiveType, PrimitiveCount, pOrigVertexBuffer8, pHackVertexBuffer8, StartVertex, 0, 0, 0);
|
||||
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
if(!g_bVBSkipStream)
|
||||
{
|
||||
#endif
|
||||
|
||||
g_pD3DDevice8->DrawPrimitive
|
||||
(
|
||||
PCPrimitiveType,
|
||||
|
@ -6158,6 +6194,10 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_DrawVertices
|
|||
PrimitiveCount
|
||||
);
|
||||
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
}
|
||||
#endif
|
||||
|
||||
// TODO: use original stride here (duh!)
|
||||
if(nStride != -1)
|
||||
EmuFixupVerticesB(nStride, pOrigVertexBuffer8, pHackVertexBuffer8);
|
||||
|
@ -6207,6 +6247,11 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_DrawVerticesUP
|
|||
|
||||
uint32 nStride = EmuFixupVerticesA(PrimitiveType, PrimitiveCount, pOrigVertexBuffer8, pHackVertexBuffer8, 0, pVertexStreamZeroData, VertexStreamZeroStride, &pNewVertexStreamZeroData);
|
||||
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
if(!g_bVBSkipStream)
|
||||
{
|
||||
#endif
|
||||
|
||||
g_pD3DDevice8->DrawPrimitiveUP
|
||||
(
|
||||
PCPrimitiveType,
|
||||
|
@ -6215,6 +6260,10 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_DrawVerticesUP
|
|||
VertexStreamZeroStride
|
||||
);
|
||||
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
}
|
||||
#endif
|
||||
|
||||
if(nStride != -1)
|
||||
{
|
||||
EmuFixupVerticesB(nStride, pOrigVertexBuffer8, pHackVertexBuffer8);
|
||||
|
@ -6296,11 +6345,20 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_DrawIndexedVertices
|
|||
|
||||
uint32 nStride = EmuFixupVerticesA(PrimitiveType, PrimitiveCount, pOrigVertexBuffer8, pHackVertexBuffer8, 0, 0, 0, 0);
|
||||
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
if(!g_bVBSkipStream)
|
||||
{
|
||||
#endif
|
||||
|
||||
g_pD3DDevice8->DrawIndexedPrimitive
|
||||
(
|
||||
PCPrimitiveType, 0, VertexCount, ((DWORD)pIndexData)/2, PrimitiveCount
|
||||
);
|
||||
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
}
|
||||
#endif
|
||||
|
||||
if(nStride != -1)
|
||||
EmuFixupVerticesB(nStride, pOrigVertexBuffer8, pHackVertexBuffer8);
|
||||
|
||||
|
@ -6354,11 +6412,20 @@ VOID WINAPI XTL::EmuIDirect3DDevice8_DrawIndexedVerticesUP
|
|||
|
||||
uint32 nStride = EmuFixupVerticesA(PrimitiveType, PrimitiveCount, pOrigVertexBuffer8, pHackVertexBuffer8, 0, pVertexStreamZeroData, VertexStreamZeroStride, &pNewVertexStreamZeroData);
|
||||
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
if(!g_bVBSkipStream)
|
||||
{
|
||||
#endif
|
||||
|
||||
g_pD3DDevice8->DrawIndexedPrimitiveUP
|
||||
(
|
||||
PCPrimitiveType, 0, VertexCount, PrimitiveCount, pIndexData, D3DFMT_INDEX16, pNewVertexStreamZeroData, VertexStreamZeroStride
|
||||
);
|
||||
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
}
|
||||
#endif
|
||||
|
||||
if(nStride != -1)
|
||||
{
|
||||
EmuFixupVerticesB(nStride, pOrigVertexBuffer8, pHackVertexBuffer8);
|
||||
|
|
|
@ -47,7 +47,9 @@ extern XTL::LPDIRECT3DDEVICE8 g_pD3DDevice8; // Direct3D8 Device
|
|||
|
||||
#ifdef _DEBUG_TRACK_VB
|
||||
|
||||
extern XTL::VBTracker g_VBTrack;
|
||||
bool XTL::g_bVBSkipStream = false;
|
||||
|
||||
XTL::VBTracker XTL::g_VBTrackTotal, XTL::g_VBTrackDisable;
|
||||
|
||||
XTL::VBTracker::~VBTracker()
|
||||
{
|
||||
|
@ -55,14 +57,19 @@ XTL::VBTracker::~VBTracker()
|
|||
|
||||
while(cur != NULL)
|
||||
{
|
||||
free(cur);
|
||||
VBNode *tmp = cur->next;
|
||||
|
||||
cur = cur->next;
|
||||
delete cur;
|
||||
|
||||
cur = tmp;
|
||||
}
|
||||
}
|
||||
|
||||
void XTL::VBTracker::insert(IDirect3DVertexBuffer8 *pVB)
|
||||
{
|
||||
if(exists(pVB))
|
||||
return;
|
||||
|
||||
if(m_head == 0)
|
||||
{
|
||||
m_tail = m_head = new VBNode();
|
||||
|
@ -73,19 +80,65 @@ void XTL::VBTracker::insert(IDirect3DVertexBuffer8 *pVB)
|
|||
m_tail->vb = pVB;
|
||||
|
||||
m_tail->next = new VBNode();
|
||||
m_tail->next->vb = 0;
|
||||
m_tail->next->next = 0;
|
||||
|
||||
m_tail = m_tail->next;
|
||||
|
||||
m_tail->vb = 0;
|
||||
m_tail->next = 0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void XTL::VBTracker::remove(IDirect3DVertexBuffer8 *pVB)
|
||||
{
|
||||
VBNode *pre = 0;
|
||||
VBNode *cur = m_head;
|
||||
|
||||
while(cur != NULL)
|
||||
{
|
||||
if(cur->vb == pVB)
|
||||
{
|
||||
if(pre != 0)
|
||||
{
|
||||
pre->next = cur->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_head = cur->next;
|
||||
|
||||
if(m_head->next == 0)
|
||||
{
|
||||
delete m_head;
|
||||
|
||||
m_head = 0;
|
||||
m_tail = 0;
|
||||
}
|
||||
}
|
||||
|
||||
delete cur;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
pre = cur;
|
||||
cur = cur->next;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
bool XTL::VBTracker::exists(IDirect3DVertexBuffer8 *pVB)
|
||||
{
|
||||
VBNode *cur = m_head;
|
||||
|
||||
while(cur != NULL)
|
||||
{
|
||||
if(cur->vb == pVB)
|
||||
return true;
|
||||
|
||||
cur = cur->next;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ PVOID WINAPI XTL::EmuRtlCreateHeap
|
|||
IN PVOID Base OPTIONAL,
|
||||
IN ULONG Reserve OPTIONAL,
|
||||
IN ULONG Commit,
|
||||
IN BOOLEAN Lock OPTIONAL,
|
||||
IN PVOID Lock OPTIONAL,
|
||||
IN PVOID RtlHeapParams OPTIONAL
|
||||
)
|
||||
{
|
||||
|
@ -744,9 +744,7 @@ VOID WINAPI XTL::EmuXapiInitProcess()
|
|||
|
||||
DbgPrintf("EmuXapi (0x%X): EmuXapiInitProcess();\n", GetCurrentThreadId());
|
||||
|
||||
// ******************************************************************
|
||||
// * Call RtlCreateHeap
|
||||
// ******************************************************************
|
||||
// call RtlCreateHeap
|
||||
{
|
||||
RTL_HEAP_PARAMETERS HeapParameters;
|
||||
|
||||
|
@ -763,7 +761,7 @@ VOID WINAPI XTL::EmuXapiInitProcess()
|
|||
|
||||
#define HEAP_GROWABLE 0x00000002
|
||||
|
||||
*XTL::EmuXapiProcessHeap = XTL::g_pRtlCreateHeap(HEAP_GROWABLE, 0, dwPeHeapReserve, dwPeHeapCommit, 0, &HeapParameters);
|
||||
*XTL::EmuXapiProcessHeap = XTL::g_pRtlCreateHeap(HEAP_GROWABLE, 0, dwPeHeapReserve, dwPeHeapCommit, NULL, &HeapParameters);
|
||||
}
|
||||
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue