2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2010 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:43:35 +00:00
|
|
|
// Refer to the license.txt file included.
|
2010-12-05 14:15:36 +00:00
|
|
|
|
2014-02-22 22:36:30 +00:00
|
|
|
#include <cstddef>
|
|
|
|
#include <string>
|
|
|
|
#include <wx/button.h>
|
|
|
|
#include <wx/choice.h>
|
|
|
|
#include <wx/msgdlg.h>
|
|
|
|
#include <wx/panel.h>
|
|
|
|
#include <wx/sizer.h>
|
|
|
|
#include <wx/textctrl.h>
|
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
#include "Common/CommonFuncs.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "Common/FileUtil.h"
|
|
|
|
#include "Common/IniFile.h"
|
|
|
|
#include "Core/ConfigManager.h"
|
|
|
|
#include "DolphinWX/Debugger/DebuggerPanel.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "DolphinWX/WxUtils.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
#include "VideoCommon/Debugger.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/TextureCacheBase.h"
|
2014-02-22 22:36:30 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
GFXDebuggerPanel::GFXDebuggerPanel(wxWindow* parent, wxWindowID id, const wxPoint& position,
|
|
|
|
const wxSize& size, long style, const wxString& title)
|
|
|
|
: wxPanel(parent, id, position, size, style, title)
|
2010-12-05 14:15:36 +00:00
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
g_pdebugger = this;
|
2011-01-31 04:36:49 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
CreateGUIControls();
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GFXDebuggerPanel::~GFXDebuggerPanel()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
g_pdebugger = nullptr;
|
|
|
|
GFXDebuggerPauseFlag = false;
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
struct PauseEventMap
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
PauseEvent event;
|
|
|
|
const wxString ListStr;
|
2010-12-05 14:15:36 +00:00
|
|
|
};
|
|
|
|
|
2013-09-23 02:48:50 +00:00
|
|
|
static PauseEventMap* pauseEventMap;
|
2010-12-05 14:15:36 +00:00
|
|
|
|
2013-09-23 02:48:50 +00:00
|
|
|
void GFXDebuggerPanel::CreateGUIControls()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
static PauseEventMap map[] = {{NEXT_FRAME, _("Frame")},
|
|
|
|
{NEXT_FLUSH, _("Flush")},
|
|
|
|
|
|
|
|
{NEXT_PIXEL_SHADER_CHANGE, _("Pixel Shader")},
|
|
|
|
{NEXT_VERTEX_SHADER_CHANGE, _("Vertex Shader")},
|
|
|
|
{NEXT_TEXTURE_CHANGE, _("Texture")},
|
|
|
|
{NEXT_NEW_TEXTURE, _("New Texture")},
|
|
|
|
|
|
|
|
{NEXT_XFB_CMD, _("XFB Cmd")},
|
|
|
|
{NEXT_EFB_CMD, _("EFB Cmd")},
|
|
|
|
|
|
|
|
{NEXT_MATRIX_CMD, _("Matrix Cmd")},
|
|
|
|
{NEXT_VERTEX_CMD, _("Vertex Cmd")},
|
|
|
|
{NEXT_TEXTURE_CMD, _("Texture Cmd")},
|
|
|
|
{NEXT_LIGHT_CMD, _("Light Cmd")},
|
|
|
|
{NEXT_FOG_CMD, _("Fog Cmd")},
|
|
|
|
|
|
|
|
{NEXT_SET_TLUT, _("TLUT Cmd")},
|
|
|
|
|
|
|
|
{NEXT_ERROR, _("Error")}};
|
|
|
|
pauseEventMap = map;
|
2016-10-03 07:29:50 +00:00
|
|
|
static constexpr int numPauseEventMap = ArraySize(map);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
const int space3 = FromDIP(3);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
m_pButtonPause = new wxButton(this, wxID_ANY, _("Pause"), wxDefaultPosition, wxDefaultSize, 0,
|
|
|
|
wxDefaultValidator, _("Pause"));
|
|
|
|
m_pButtonPause->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnPauseButton, this);
|
|
|
|
|
|
|
|
m_pButtonPauseAtNext = new wxButton(this, wxID_ANY, _("Pause After"), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0, wxDefaultValidator, _("Pause At Next"));
|
|
|
|
m_pButtonPauseAtNext->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnPauseAtNextButton, this);
|
|
|
|
|
|
|
|
m_pButtonPauseAtNextFrame = new wxButton(this, wxID_ANY, _("Go to Next Frame"), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0, wxDefaultValidator, _("Next Frame"));
|
|
|
|
m_pButtonPauseAtNextFrame->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnPauseAtNextFrameButton, this);
|
|
|
|
|
|
|
|
m_pButtonCont = new wxButton(this, wxID_ANY, _("Continue"), wxDefaultPosition, wxDefaultSize, 0,
|
|
|
|
wxDefaultValidator, _("Continue"));
|
|
|
|
m_pButtonCont->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnContButton, this);
|
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
m_pCount = new wxTextCtrl(this, wxID_ANY, "1", wxDefaultPosition, wxDefaultSize, wxTE_RIGHT,
|
2016-06-24 08:43:46 +00:00
|
|
|
wxDefaultValidator, _("Count"));
|
2016-10-03 07:29:50 +00:00
|
|
|
m_pCount->SetMinSize(WxUtils::GetTextWidgetMinSize(m_pCount, 10000));
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
m_pPauseAtList = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr, 0,
|
2016-06-24 08:43:46 +00:00
|
|
|
wxDefaultValidator, _("PauseAtList"));
|
|
|
|
for (int i = 0; i < numPauseEventMap; i++)
|
|
|
|
{
|
|
|
|
m_pPauseAtList->Append(pauseEventMap[i].ListStr);
|
|
|
|
}
|
|
|
|
m_pPauseAtList->SetSelection(0);
|
|
|
|
|
|
|
|
m_pButtonDump = new wxButton(this, wxID_ANY, _("Dump"), wxDefaultPosition, wxDefaultSize, 0,
|
|
|
|
wxDefaultValidator, _("Dump"));
|
|
|
|
m_pButtonDump->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnDumpButton, this);
|
|
|
|
|
|
|
|
m_pButtonUpdateScreen = new wxButton(this, wxID_ANY, _("Update Screen"), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0, wxDefaultValidator, _("Update Screen"));
|
|
|
|
m_pButtonUpdateScreen->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnUpdateScreenButton, this);
|
|
|
|
|
|
|
|
m_pButtonClearScreen = new wxButton(this, wxID_ANY, _("Clear Screen"), wxDefaultPosition,
|
|
|
|
wxDefaultSize, 0, wxDefaultValidator, _("Clear Screen"));
|
|
|
|
m_pButtonClearScreen->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnClearScreenButton, this);
|
|
|
|
|
|
|
|
m_pButtonClearTextureCache =
|
|
|
|
new wxButton(this, wxID_ANY, _("Clear Textures"), wxDefaultPosition, wxDefaultSize, 0,
|
|
|
|
wxDefaultValidator, _("Clear Textures"));
|
|
|
|
m_pButtonClearTextureCache->Bind(wxEVT_BUTTON, &GFXDebuggerPanel::OnClearTextureCacheButton,
|
|
|
|
this);
|
|
|
|
|
|
|
|
m_pButtonClearVertexShaderCache =
|
|
|
|
new wxButton(this, wxID_ANY, _("Clear V Shaders"), wxDefaultPosition, wxDefaultSize, 0,
|
|
|
|
wxDefaultValidator, _("Clear V Shaders"));
|
|
|
|
m_pButtonClearVertexShaderCache->Bind(wxEVT_BUTTON,
|
|
|
|
&GFXDebuggerPanel::OnClearVertexShaderCacheButton, this);
|
|
|
|
|
|
|
|
m_pButtonClearPixelShaderCache =
|
|
|
|
new wxButton(this, wxID_ANY, _("Clear P Shaders"), wxDefaultPosition, wxDefaultSize, 0,
|
|
|
|
wxDefaultValidator, _("Clear P Shaders"));
|
|
|
|
m_pButtonClearPixelShaderCache->Bind(wxEVT_BUTTON,
|
|
|
|
&GFXDebuggerPanel::OnClearPixelShaderCacheButton, this);
|
|
|
|
|
2016-10-03 07:29:50 +00:00
|
|
|
m_pDumpList = new wxChoice(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, nullptr, 0,
|
2016-06-24 08:43:46 +00:00
|
|
|
wxDefaultValidator, _("DumpList"));
|
|
|
|
m_pDumpList->Insert(_("Pixel Shader"), 0);
|
|
|
|
m_pDumpList->Append(_("Vertex Shader"));
|
|
|
|
m_pDumpList->Append(_("Pixel Shader Constants"));
|
|
|
|
m_pDumpList->Append(_("Vertex Shader Constants"));
|
|
|
|
m_pDumpList->Append(_("Textures"));
|
|
|
|
m_pDumpList->Append(_("Frame Buffer"));
|
|
|
|
m_pDumpList->Append(_("Geometry data"));
|
|
|
|
m_pDumpList->Append(_("Vertex Description"));
|
|
|
|
m_pDumpList->Append(_("Vertex Matrices"));
|
|
|
|
m_pDumpList->Append(_("Statistics"));
|
|
|
|
m_pDumpList->SetSelection(0);
|
|
|
|
|
|
|
|
wxBoxSizer* sMain = new wxBoxSizer(wxVERTICAL);
|
|
|
|
|
|
|
|
wxBoxSizer* const pPauseAtNextSzr = new wxBoxSizer(wxHORIZONTAL);
|
2016-10-03 07:29:50 +00:00
|
|
|
pPauseAtNextSzr->Add(m_pCount, 0, wxALIGN_CENTER_VERTICAL);
|
|
|
|
pPauseAtNextSzr->Add(m_pPauseAtList, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, space3);
|
|
|
|
|
|
|
|
wxFlexGridSizer* const flow_szr = new wxFlexGridSizer(2, space3, space3);
|
|
|
|
flow_szr->Add(m_pButtonPause, 0, wxEXPAND);
|
|
|
|
flow_szr->AddSpacer(1);
|
|
|
|
flow_szr->Add(m_pButtonPauseAtNext, 0, wxEXPAND);
|
|
|
|
flow_szr->Add(pPauseAtNextSzr, 0, wxEXPAND);
|
|
|
|
flow_szr->Add(m_pButtonPauseAtNextFrame, 0, wxEXPAND);
|
|
|
|
flow_szr->AddSpacer(1);
|
|
|
|
flow_szr->Add(m_pButtonCont, 0, wxEXPAND);
|
|
|
|
flow_szr->AddSpacer(1);
|
|
|
|
|
|
|
|
wxStaticBoxSizer* const pFlowCtrlBox = new wxStaticBoxSizer(wxVERTICAL, this, _("Flow Control"));
|
|
|
|
pFlowCtrlBox->Add(flow_szr, 1, wxEXPAND);
|
2016-06-24 08:43:46 +00:00
|
|
|
|
|
|
|
wxBoxSizer* const pDumpSzr = new wxBoxSizer(wxHORIZONTAL);
|
2016-10-03 07:29:50 +00:00
|
|
|
pDumpSzr->Add(m_pButtonDump, 0, wxALIGN_CENTER_VERTICAL);
|
|
|
|
pDumpSzr->Add(m_pDumpList, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, space3);
|
|
|
|
|
|
|
|
wxGridSizer* const pDbgGrid = new wxGridSizer(2, space3, space3);
|
|
|
|
pDbgGrid->Add(m_pButtonUpdateScreen, 0, wxEXPAND);
|
|
|
|
pDbgGrid->Add(m_pButtonClearScreen, 0, wxEXPAND);
|
|
|
|
pDbgGrid->Add(m_pButtonClearTextureCache, 0, wxEXPAND);
|
|
|
|
pDbgGrid->Add(m_pButtonClearVertexShaderCache, 0, wxEXPAND);
|
|
|
|
pDbgGrid->Add(m_pButtonClearPixelShaderCache, 0, wxEXPAND);
|
|
|
|
|
|
|
|
wxStaticBoxSizer* const pDebugBox = new wxStaticBoxSizer(wxVERTICAL, this, _("Debugging"));
|
|
|
|
pDebugBox->Add(pDumpSzr, 0, wxEXPAND);
|
|
|
|
pDebugBox->Add(pDbgGrid, 1, wxTOP, space3);
|
|
|
|
|
|
|
|
sMain->Add(pFlowCtrlBox);
|
|
|
|
sMain->Add(pDebugBox);
|
2016-06-24 08:43:46 +00:00
|
|
|
SetSizerAndFit(sMain);
|
|
|
|
|
|
|
|
OnContinue();
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GFXDebuggerPanel::OnPause()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_pButtonDump->Enable();
|
|
|
|
m_pDumpList->Enable();
|
|
|
|
m_pButtonUpdateScreen->Enable();
|
|
|
|
m_pButtonClearScreen->Enable();
|
|
|
|
m_pButtonClearTextureCache->Enable();
|
|
|
|
m_pButtonClearVertexShaderCache->Enable();
|
|
|
|
m_pButtonClearPixelShaderCache->Enable();
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GFXDebuggerPanel::OnContinue()
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
m_pButtonDump->Disable();
|
|
|
|
m_pDumpList->Disable();
|
|
|
|
m_pButtonUpdateScreen->Disable();
|
|
|
|
m_pButtonClearScreen->Disable();
|
|
|
|
m_pButtonClearTextureCache->Disable();
|
|
|
|
m_pButtonClearVertexShaderCache->Disable();
|
|
|
|
m_pButtonClearPixelShaderCache->Disable();
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GFXDebuggerPanel::OnPauseButton(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
GFXDebuggerPauseFlag = true;
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GFXDebuggerPanel::OnPauseAtNextButton(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
GFXDebuggerPauseFlag = false;
|
|
|
|
GFXDebuggerToPauseAtNext = pauseEventMap[m_pPauseAtList->GetSelection()].event;
|
|
|
|
wxString val = m_pCount->GetValue();
|
|
|
|
long value;
|
|
|
|
if (val.ToLong(&value))
|
|
|
|
GFXDebuggerEventToPauseCount = value;
|
|
|
|
else
|
|
|
|
GFXDebuggerEventToPauseCount = 1;
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GFXDebuggerPanel::OnPauseAtNextFrameButton(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
GFXDebuggerPauseFlag = false;
|
|
|
|
GFXDebuggerToPauseAtNext = NEXT_FRAME;
|
|
|
|
GFXDebuggerEventToPauseCount = 1;
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GFXDebuggerPanel::OnDumpButton(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
std::string dump_path =
|
2016-10-29 12:42:43 +00:00
|
|
|
File::GetUserPath(D_DUMP_IDX) + "Debug/" + SConfig::GetInstance().m_strGameID + "/";
|
2016-06-24 08:43:46 +00:00
|
|
|
if (!File::CreateFullPath(dump_path))
|
|
|
|
return;
|
|
|
|
|
|
|
|
switch (m_pDumpList->GetSelection())
|
|
|
|
{
|
|
|
|
case 0: // Pixel Shader
|
|
|
|
DumpPixelShader(dump_path);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 1: // Vertex Shader
|
|
|
|
DumpVertexShader(dump_path);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 2: // Pixel Shader Constants
|
|
|
|
DumpPixelShaderConstants(dump_path);
|
|
|
|
WxUtils::ShowErrorDialog(_("Not implemented"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 3: // Vertex Shader Constants
|
|
|
|
DumpVertexShaderConstants(dump_path);
|
|
|
|
WxUtils::ShowErrorDialog(_("Not implemented"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 4: // Textures
|
|
|
|
DumpTextures(dump_path);
|
|
|
|
WxUtils::ShowErrorDialog(_("Not implemented"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 5: // Frame Buffer
|
|
|
|
DumpFrameBuffer(dump_path);
|
|
|
|
WxUtils::ShowErrorDialog(_("Not implemented"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 6: // Geometry
|
|
|
|
DumpGeometry(dump_path);
|
|
|
|
WxUtils::ShowErrorDialog(_("Not implemented"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7: // Vertex Description
|
|
|
|
DumpVertexDecl(dump_path);
|
|
|
|
WxUtils::ShowErrorDialog(_("Not implemented"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 8: // Vertex Matrices
|
|
|
|
DumpMatrices(dump_path);
|
|
|
|
WxUtils::ShowErrorDialog(_("Not implemented"));
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 9: // Statistics
|
|
|
|
DumpStats(dump_path);
|
|
|
|
WxUtils::ShowErrorDialog(_("Not implemented"));
|
|
|
|
break;
|
|
|
|
}
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GFXDebuggerPanel::OnContButton(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
GFXDebuggerToPauseAtNext = NOT_PAUSE;
|
|
|
|
GFXDebuggerPauseFlag = false;
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GFXDebuggerPanel::OnClearScreenButton(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
// TODO
|
|
|
|
WxUtils::ShowErrorDialog(_("Not implemented"));
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GFXDebuggerPanel::OnClearTextureCacheButton(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
TextureCacheBase::Invalidate();
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GFXDebuggerPanel::OnClearVertexShaderCacheButton(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
// TODO
|
|
|
|
WxUtils::ShowErrorDialog(_("Not implemented"));
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GFXDebuggerPanel::OnClearPixelShaderCacheButton(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
// TODO
|
|
|
|
WxUtils::ShowErrorDialog(_("Not implemented"));
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void GFXDebuggerPanel::OnUpdateScreenButton(wxCommandEvent& event)
|
|
|
|
{
|
2016-06-24 08:43:46 +00:00
|
|
|
WxUtils::ShowErrorDialog(_("Not implemented"));
|
|
|
|
GFXDebuggerUpdateScreen();
|
2010-12-05 14:15:36 +00:00
|
|
|
}
|