D3D: some changes about debugger, not useful for anyone else, and should not affact anything. So not very interesting, just get ready to do some debugging.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4297 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
rice1964 2009-09-18 02:03:56 +00:00
parent 57f7b668ad
commit 8b4839a4f4
8 changed files with 130 additions and 155 deletions

View File

@ -40,7 +40,7 @@ static bool auto_depth_stencil = false;
#define VENDOR_NVIDIA 4318
#define VENDOR_ATI 4098
static bool bFrameInProgress = false;
bool bFrameInProgress = false;
#define MAX_ADAPTERS 4
static Adapter adapters[MAX_ADAPTERS];

View File

@ -49,6 +49,7 @@ void Shutdown();
// Direct access to the device.
extern IDirect3DDevice9 *dev;
extern bool bFrameInProgress;
void Reset();
bool BeginFrame();

View File

@ -22,6 +22,7 @@
#include "VideoConfig.h"
#include "../Globals.h"
#include "../D3DBase.h"
#include "../FramebufferManager.h"
extern int g_Preset;
@ -35,6 +36,7 @@ BEGIN_EVENT_TABLE(GFXDebuggerDX9,wxDialog)
EVT_CHECKBOX(ID_SAVESHADERS,GFXDebuggerDX9::GeneralSettings)
EVT_BUTTON(ID_PAUSE,GFXDebuggerDX9::OnPauseButton)
EVT_BUTTON(ID_PAUSE_AT_NEXT,GFXDebuggerDX9::OnPauseAtNextButton)
EVT_BUTTON(ID_PAUSE_AT_NEXT_FRAME,GFXDebuggerDX9::OnPauseAtNextFrameButton)
EVT_BUTTON(ID_GO,GFXDebuggerDX9::OnGoButton)
EVT_BUTTON(ID_DUMP,GFXDebuggerDX9::OnDumpButton)
EVT_BUTTON(ID_UPDATE_SCREEN,GFXDebuggerDX9::OnUpdateScreenButton)
@ -119,6 +121,42 @@ void GFXDebuggerDX9::LoadSettings()
//m_Check[5]->SetValue(bSaveShaders);
}
struct PauseEventMap
{
PauseEvent event;
const wxString ListStr;
};
static PauseEventMap pauseEventMap[] = {
{NEXT_FRAME, wxT("Frame")},
{NEXT_FLUSH, wxT("Flush")},
{NEXT_PIXEL_SHADER_CHANGE, wxT("Pixel Shader")},
{NEXT_VERTEX_SHADER_CHANGE, wxT("Vertex Shader")},
{NEXT_TEXTURE_CHANGE, wxT("Texture")},
{NEXT_NEW_TEXTURE, wxT("New Texture")},
{NEXT_XFB_CMD, wxT("XFB Cmd")},
{NEXT_EFB_CMD, wxT("EFB Cmd")},
{NEXT_MATRIX_CMD, wxT("Matrix Cmd")},
{NEXT_VERTEX_CMD, wxT("Vertex Cmd")},
{NEXT_TEXTURE_CMD, wxT("Texture Cmd")},
{NEXT_LIGHT_CMD, wxT("Light Cmd")},
{NEXT_FOG_CMD, wxT("Fog Cmd")},
{NEXT_SET_TLUT, wxT("TLUT Cmd")},
{NEXT_FIFO, wxT("Fifo")},
{NEXT_DLIST, wxT("DList")},
{NEXT_UCODE, wxT("Ucode")},
{NEXT_ERROR, wxT("Error")}
};
static const int numPauseEventMap = sizeof(pauseEventMap)/sizeof(PauseEventMap);
void GFXDebuggerDX9::CreateGUIControls()
{
// Basic settings
@ -139,26 +177,15 @@ void GFXDebuggerDX9::CreateGUIControls()
m_pButtonPause = new wxButton(m_MainPanel, ID_PAUSE, wxT("Pause"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("Pause"));
m_pButtonPauseAtNext = new wxButton(m_MainPanel, ID_PAUSE_AT_NEXT, wxT("Pause At Next"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("Pause At Next"));
m_pButtonPauseAtNextFrame = new wxButton(m_MainPanel, ID_PAUSE_AT_NEXT_FRAME, wxT("Next Frame"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("Next Frame"));
m_pButtonGo = new wxButton(m_MainPanel, ID_GO, wxT("Go"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("Go"));
m_pPauseAtList = new wxChoice(m_MainPanel, ID_PAUSE_AT_LIST, wxDefaultPosition, wxSize(100,25), 0, NULL,0,wxDefaultValidator, wxT("PauseAtList"));
//m_pPauseAtList->SetEditable(false);
m_pPauseAtList->Insert(wxT("Frame"),0);
m_pPauseAtList->Append(wxT("Flush"));
m_pPauseAtList->Append(wxT("Fifo"));
m_pPauseAtList->Append(wxT("Dlist Call"));
m_pPauseAtList->Append(wxT("Pixel Shader Change"));
m_pPauseAtList->Append(wxT("Vertex Shader Change"));
m_pPauseAtList->Append(wxT("New Texture"));
m_pPauseAtList->Append(wxT("Render To Texture"));
m_pPauseAtList->Append(wxT("Matrix Ucode"));
m_pPauseAtList->Append(wxT("Vertex Ucode"));
m_pPauseAtList->Append(wxT("Texture Ucode"));
m_pPauseAtList->Append(wxT("Light Ucode"));
m_pPauseAtList->Append(wxT("Frame Buffer Command"));
m_pPauseAtList->Append(wxT("Fog Command"));
m_pPauseAtList->Append(wxT("Set Color Constant"));
m_pPauseAtList->Append(wxT("Ucode"));
for (int i=0; i<numPauseEventMap; i++)
{
m_pPauseAtList->Append(pauseEventMap[i].ListStr);
}
m_pPauseAtList->SetSelection(0);
m_pButtonDump = new wxButton(m_MainPanel, ID_DUMP, wxT("Dump"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("Dump"));
@ -201,6 +228,7 @@ void GFXDebuggerDX9::CreateGUIControls()
sMain->Add(m_pDumpList, 0, 0, 5);
sMain->Add(m_pButtonUpdateScreen, 0, 0, 5);
sMain->Add(m_pButtonClearScreen, 0, 0, 5);
sMain->Add(m_pButtonPauseAtNextFrame, 0, 0, 5);
sMain->Add(m_pButtonGo, 0, 0, 5);
m_MainPanel->SetSizerAndFit(sMain);
Fit();
@ -246,11 +274,18 @@ void GFXDebuggerDX9::OnPauseAtNextButton(wxCommandEvent& event)
wxString val = m_pCount->GetValue();
long value;
if (val.ToLong(&value) )
DX9DebuggerEventToPauseCount = PauseEvent(value);
DX9DebuggerEventToPauseCount = pauseEventMap[value].event;
else
DX9DebuggerEventToPauseCount = 1;
}
void GFXDebuggerDX9::OnPauseAtNextFrameButton(wxCommandEvent& event)
{
DX9DebuggerPauseFlag = false;
DX9DebuggerToPauseAtNext = NEXT_FRAME;
DX9DebuggerEventToPauseCount = 1;
}
void GFXDebuggerDX9::OnDumpButton(wxCommandEvent& event)
{
}
@ -269,42 +304,57 @@ void GFXDebuggerDX9::OnClearScreenButton(wxCommandEvent& event)
}
void UpdateFPSDisplay(const char *text);
void DX9DebuggerCheckAndPause()
extern bool D3D::bFrameInProgress;
static void DX9DebuggerUpdateScreen()
{
//update screen
if (D3D::bFrameInProgress)
{
D3D::dev->SetRenderTarget(0, D3D::GetBackBufferSurface());
D3D::dev->SetDepthStencilSurface(NULL);
D3D::dev->StretchRect(FBManager::GetEFBColorRTSurface(), NULL,
D3D::GetBackBufferSurface(), NULL,
D3DTEXF_LINEAR);
D3D::dev->EndScene();
D3D::dev->Present(NULL, NULL, NULL, NULL);
D3D::dev->SetRenderTarget(0, FBManager::GetEFBColorRTSurface());
D3D::dev->SetDepthStencilSurface(FBManager::GetEFBDepthRTSurface());
D3D::dev->BeginScene();
}
else
{
D3D::dev->EndScene();
D3D::dev->Present(NULL, NULL, NULL, NULL);
D3D::dev->BeginScene();
}
}
void DX9DebuggerCheckAndPause(bool update)
{
while( DX9DebuggerPauseFlag )
{
UpdateFPSDisplay("Paused by Video Debugger");
if (update) DX9DebuggerUpdateScreen();
Sleep(5);
}
}
void DX9DebuggerToPause(bool update)
{
DX9DebuggerToPauseAtNext = NOT_PAUSE;
DX9DebuggerPauseFlag = true;
DX9DebuggerCheckAndPause(update);
}
void ContinueDX9Debugger()
{
DX9DebuggerPauseFlag = false;
}
#ifdef ENABLE_DX_DEBUGGER
void DX9Debugger_Pause_Count_N(PauseEvent event,bool update)
{
if (DX9DebuggerToPauseAtNext == event || DX9DebuggerPauseFlag)
{
DX9DebuggerEventToPauseCount--;
if (DX9DebuggerEventToPauseCount<=0 || DX9DebuggerPauseFlag)
{
DX9DebuggerToPauseAtNext = NOT_PAUSE;
DX9DebuggerPauseFlag = true;
if (update)
{
D3D::EndFrame();
D3D::BeginFrame();
}
DX9DebuggerCheckAndPause();
}
}
}
#endif ENABLE_DX_DEBUGGER

View File

@ -58,6 +58,7 @@ private:
wxCheckBox *m_Check[6];
wxButton *m_pButtonPause;
wxButton *m_pButtonPauseAtNext;
wxButton *m_pButtonPauseAtNextFrame;
wxButton *m_pButtonGo;
wxChoice *m_pPauseAtList;
wxButton *m_pButtonDump;
@ -81,6 +82,7 @@ private:
ID_GO,
ID_PAUSE,
ID_PAUSE_AT_NEXT,
ID_PAUSE_AT_NEXT_FRAME,
ID_PAUSE_AT_LIST,
ID_DUMP,
ID_DUMP_LIST,
@ -95,6 +97,7 @@ private:
void GeneralSettings(wxCommandEvent& event);
void OnPauseButton(wxCommandEvent& event);
void OnPauseAtNextButton(wxCommandEvent& event);
void OnPauseAtNextFrameButton(wxCommandEvent& event);
void OnDumpButton(wxCommandEvent& event);
void OnGoButton(wxCommandEvent& event);
void OnUpdateScreenButton(wxCommandEvent& event);
@ -105,26 +108,29 @@ private:
enum PauseEvent {
NEXT_FRAME,
NEXT_FLUSH,
NEXT_FIFO,
NEXT_DLIST,
NEXT_PIXEL_SHADER_CHANGE,
NEXT_VERTEX_SHADER_CHANGE,
NEXT_TEXTURE_CHANGE,
NEXT_NEW_TEXTURE,
NEXT_RENDER_TEXTURE,
NEXT_XFB_CMD,
NEXT_EFB_CMD,
NEXT_MATRIX_CMD,
NEXT_VERTEX_CMD,
NEXT_TEXTURE_CMD,
NEXT_LIGHT_CMD,
NEXT_FRAME_BUFFER_CMD,
NEXT_FOG_CMD,
NEXT_SET_CONSTANT_COLOR,
NEXT_SET_TLUT,
NEXT_FIFO,
NEXT_DLIST,
NEXT_UCODE,
NEXT_SET_TEXTURE,
NEXT_SET_LIGHT,
NEXT_SET_MODE_CMD,
NEXT_UNKNOWN_OP,
NEXT_LOADTLUT,
NEXT_SWITCH_UCODE,
NEXT_ERROR,
NOT_PAUSE,
};
@ -132,110 +138,23 @@ extern volatile bool DX9DebuggerPauseFlag;
extern volatile PauseEvent DX9DebuggerToPauseAtNext;
extern volatile int DX9DebuggerEventToPauseCount;
void ContinueDX9Debugger();
void DX9DebuggerCheckAndPause();
void DX9DebuggerCheckAndPause(bool update);
void DX9DebuggerToPause(bool update);
#undef ENABLE_DX_DEBUGGER
#ifdef _DEBUG
#if defined(_DEBUG) || defined(DEBUGFAST)
#define ENABLE_DX_DEBUGGER
#else
#ifdef DEBUGFAST
#define ENABLE_DX_DEBUGGER
#endif
#endif
#ifdef ENABLE_DX_DEBUGGER
#define DX9DEBUGGER_PAUSE {DX9DebuggerCheckAndPause();}
#define DX9DEBUGGER_PAUSE_IF(op) if(DX9DebuggerToPauseAtNext == op && DX9DebuggerToPauseAtNext!=NOT_PAUSE){DX9DebuggerToPauseAtNext = NOT_PAUSE;DX9DebuggerPauseFlag = true;DX9DebuggerCheckAndPause();}
#define DEBUGGER_PAUSE_COUNT_N(PauseEvent) DX9Debugger_Pause_Count_N(PauseEvent,true)
#define DEBUGGER_PAUSE_COUNT_N_WITHOUT_UPDATE(PauseEvent) DX9Debugger_Pause_Count_N(PauseEvent,false)
extern void DX9Debugger_Pause_Count_N(PauseEvent,bool);
//#define DebuggerPauseCountN DEBUGGER_PAUSE_COUNT_N
//#define DEBUGGER_PAUSE_AND_DUMP(op,dumpfuc) \
// if(pauseAtNext && eventToPause == op) \
// { pauseAtNext = false;debuggerPause = true; CGraphicsContext::Get()->UpdateFrame(); dumpfuc;}
//#define DEBUGGER_PAUSE_AND_DUMP_NO_UPDATE(op,dumpfuc) \
// if(pauseAtNext && eventToPause == op) \
// { pauseAtNext = false;debuggerPause = true; dumpfuc;}
//
//#define DEBUGGER_PAUSE_AND_DUMP_COUNT_N(op,dumpfuc) \
// if(pauseAtNext && eventToPause == op) \
//{ if( debuggerPauseCount > 0 ) debuggerPauseCount--; if( debuggerPauseCount == 0 ){pauseAtNext = false;debuggerPause = true; CGraphicsContext::Get()->UpdateFrame(); dumpfuc;}}
//
//#define DEBUGGER_PAUSE_AT_COND_AND_DUMP_COUNT_N(cond,dumpfuc) \
// if(pauseAtNext && (cond) ) \
//{ if( debuggerPauseCount > 0 ) debuggerPauseCount--; if( debuggerPauseCount == 0 ){pauseAtNext = false;debuggerPause = true; CGraphicsContext::Get()->UpdateFrame(); dumpfuc;}}
//
//void RDP_NOIMPL_Real(LPCTSTR op,u32,u32) ;
//#define RSP_RDP_NOIMPL RDP_NOIMPL_Real
//#define DEBUGGER_IF_DUMP(cond, dumpfunc) {if(cond) {dumpfunc}}
//#define TXTRBUF_DUMP(dumpfunc) DEBUGGER_IF_DUMP((logTextureBuffer), dumpfunc)
//#define TXTRBUF_DETAIL_DUMP(dumpfunc) DEBUGGER_IF_DUMP((logTextureBuffer&&logDetails), dumpfunc)
//#define TXTRBUF_OR_CI_DUMP(dumpfunc) DEBUGGER_IF_DUMP((logTextureBuffer || (pauseAtNext && eventToPause == NEXT_SET_CIMG)), dumpfunc)
//#define TXTRBUF_OR_CI_DETAIL_DUMP(dumpfunc) DEBUGGER_IF_DUMP(((logTextureBuffer || (pauseAtNext && eventToPause == NEXT_SET_CIMG))&&logDetails), dumpfunc)
//#define VTX_DUMP(dumpfunc) DEBUGGER_IF_DUMP((logVertex && pauseAtNext), dumpfunc)
//#define TRI_DUMP(dumpfunc) DEBUGGER_IF_DUMP((logTriangles && pauseAtNext), dumpfunc)
//#define LIGHT_DUMP(dumpfunc) DEBUGGER_IF_DUMP((eventToPause == NEXT_SET_LIGHT && pauseAtNext), dumpfunc)
//#define WARNING(dumpfunc) DEBUGGER_IF_DUMP(logWarning, dumpfunc)
//#define FOG_DUMP(dumpfunc) DEBUGGER_IF_DUMP(logFog, dumpfunc)
//#define LOG_TEXTURE(dumpfunc) DEBUGGER_IF_DUMP((logTextures || (pauseAtNext && eventToPause==NEXT_TEXTURE_CMD) ), dumpfunc)
//#define DEBUGGER_ONLY_IF DEBUGGER_IF_DUMP
//#define DEBUGGER_ONLY(func) {func}
//
//#define TRACE0(arg0) {DebuggerAppendMsg(arg0);}
//#define TRACE1(arg0,arg1) {DebuggerAppendMsg(arg0,arg1);}
//#define TRACE2(arg0,arg1,arg2) {DebuggerAppendMsg(arg0,arg1,arg2);}
//#define TRACE3(arg0,arg1,arg2,arg3) {DebuggerAppendMsg(arg0,arg1,arg2,arg3);}
//#define TRACE4(arg0,arg1,arg2,arg3,arg4) {DebuggerAppendMsg(arg0,arg1,arg2,arg3,arg4);}
//#define TRACE5(arg0,arg1,arg2,arg3,arg4,arg5) {DebuggerAppendMsg(arg0,arg1,arg2,arg3,arg4,arg5);}
//#define DEBUG_TRIANGLE(dumpfunc) { if(pauseAtNext && eventToPause==NEXT_TRIANGLE ) { eventToPause = NEXT_FLUSH_TRI; debuggerPause = true; DEBUGGER_PAUSE(NEXT_FLUSH_TRI); dumpfunc} }
#define DEBUGGER_PAUSE_AT(event,update) {if ((DX9DebuggerToPauseAtNext == event && --DX9DebuggerEventToPauseCount<=0) || DX9DebuggerPauseFlag) DX9DebuggerToPause(update);}
#define DEBUGGER_PAUSE_LOG_AT(event,update,dumpfunc) {if ((DX9DebuggerToPauseAtNext == event && --DX9DebuggerEventToPauseCount<=0) || DX9DebuggerPauseFlag) {{dumpfunc};DX9DebuggerToPause(update);}}
#else
// Not to use debugger in release build
#define DX9DEBUGGER_PAUSE
#define DX9DEBUGGER_PAUSE_IF(op)
#define DEBUGGER_PAUSE(op)
#define DEBUGGER_PAUSE_COUNT_N(op)
#define DEBUGGER_PAUSE_COUNT_N_WITHOUT_UPDATE(PauseEvent)
//#define DEBUG_DUMP_VERTEXES(str, v0, v1, v2)
//#define DEBUGGER_IF(op)
//#define DEBUGGER_PAUSE_AND_DUMP(op,dumpfuc)
//#define DebuggerPauseCountN DEBUGGER_PAUSE_COUNT_N
//#define DEBUGGER_PAUSE_AT_COND_AND_DUMP_COUNT_N(cond,dumpfuc)
//#define DEBUGGER_PAUSE_AND_DUMP_COUNT_N(op,dumpfuc)
//#define DEBUGGER_PAUSE_COUNT_N_WITHOUT_UPDATE(op)
//#define DEBUGGER_PAUSE_AND_DUMP_NO_UPDATE(op,dumpfuc)
//#define RSP_RDP_NOIMPL(a,b,c)
//void __cdecl DebuggerAppendMsg(const char * Message, ...);
//#define DumpHex(rdramAddr, count)
//#define DEBUGGER_IF_DUMP(cond, dumpfunc)
//#define TXTRBUF_DUMP(dumpfunc)
//#define TXTRBUF_DETAIL_DUMP(dumpfunc)
//#define TXTRBUF_OR_CI_DUMP(dumpfunc)
//#define TXTRBUF_OR_CI_DETAIL_DUMP(dumpfunc)
//#define VTX_DUMP(dumpfunc)
//#define TRI_DUMP(dumpfunc)
//#define LIGHT_DUMP(dumpfunc)
//#define WARNING(dumpfunc)
//#define FOG_DUMP(dumpfunc)
//#define LOG_TEXTURE(dumpfunc)
//#define DEBUGGER_ONLY_IF DEBUGGER_IF_DUMP
//#define DEBUGGER_ONLY(func)
//#define DumpMatrix(a,b)
//
//#define TRACE0(arg0) {}
//#define TRACE1(arg0,arg1) {}
//#define TRACE2(arg0,arg1,arg2) {}
//#define TRACE3(arg0,arg1,arg2,arg3) {}
//#define TRACE4(arg0,arg1,arg2,arg3,arg4) {}
//#define TRACE5(arg0,arg1,arg2,arg3,arg4,arg5) {}
//
//#define DEBUG_TRIANGLE(arg0) {}
#define DEBUGGER_PAUSE_AT(event,update)
#define DEBUGGER_PAUSE_LOG_AT(event,update,dumpfunc)
#endif ENABLE_DX_DEBUGGER

View File

@ -109,7 +109,7 @@ bool PixelShaderCache::SetShader(bool dstAlpha)
last_entry = &entry;
DEBUGGER_PAUSE_COUNT_N(NEXT_PIXEL_SHADER_CHANGE);
DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE,true);
if (entry.shader)
{

View File

@ -243,6 +243,7 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
if (g_bSkipCurrentFrame)
{
g_VideoInitialize.pCopiedToXFB(false);
DEBUGGER_PAUSE_LOG_AT(NEXT_XFB_CMD,false,{printf("RenderToXFB - disabled");});
return;
}
@ -334,8 +335,6 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
OSD::DrawMessages();
D3D::EndFrame();
DEBUGGER_PAUSE_COUNT_N_WITHOUT_UPDATE(NEXT_FRAME);
// D3D frame is now over
// Clean out old stuff from caches.
frameCount++;
@ -351,6 +350,10 @@ void Renderer::RenderToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRect
CheckForResize();
DEBUGGER_PAUSE_LOG_AT(NEXT_XFB_CMD,false,{printf("RenderToXFB");});
DEBUGGER_PAUSE_AT(NEXT_FRAME,false);
// Begin new frame
// Set default viewport and scissor, for the clear to work correctly
@ -491,6 +494,8 @@ u32 Renderer::AccessEFB(EFBAccessType type, int x, int y)
break;
}
DEBUGGER_PAUSE_LOG_AT(NEXT_EFB_CMD,true,{printf("AccessEFB, type = %d",type);});
return 0;
}

View File

@ -307,7 +307,7 @@ void Flush()
shader_fail:
collection = C_NOTHING;
VertexManager::s_pCurBufferPointer = fakeVBuffer;
DEBUGGER_PAUSE_COUNT_N(NEXT_FLUSH);
DEBUGGER_PAUSE_AT(NEXT_FLUSH,true);
}
//DX9DEBUGGER_PAUSE_IF(NEXT_FLUSH);
}

View File

@ -137,7 +137,7 @@ bool VertexShaderCache::SetShader(u32 components)
const VSCacheEntry &entry = iter->second;
last_entry = &entry;
DEBUGGER_PAUSE_COUNT_N(NEXT_VERTEX_SHADER_CHANGE);
DEBUGGER_PAUSE_AT(NEXT_VERTEX_SHADER_CHANGE,true);
if (entry.shader)
{
D3D::dev->SetVertexShader(entry.shader);