diff --git a/Source/Dolphin.sln b/Source/Dolphin.sln index b939bb694d..141ce51087 100644 --- a/Source/Dolphin.sln +++ b/Source/Dolphin.sln @@ -217,6 +217,7 @@ Global {F0B874CB-4476-4199-9315-8343D05AE684}.Release|x64.ActiveCfg = Release|x64 {F0B874CB-4476-4199-9315-8343D05AE684}.Release|x64.Build.0 = Release|x64 {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}.Debug|Win32.ActiveCfg = Debug|Win32 + {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}.Debug|Win32.Build.0 = Debug|Win32 {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}.Debug|x64.ActiveCfg = Debug|x64 {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}.Debug|x64.Build.0 = Debug|x64 {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 @@ -232,6 +233,7 @@ Global {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}.Release|x64.ActiveCfg = Release|x64 {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}.Release|x64.Build.0 = Release|x64 {9A183B48-ECC2-4121-876A-9B3793686073}.Debug|Win32.ActiveCfg = Debug|Win32 + {9A183B48-ECC2-4121-876A-9B3793686073}.Debug|Win32.Build.0 = Debug|Win32 {9A183B48-ECC2-4121-876A-9B3793686073}.Debug|x64.ActiveCfg = Debug|x64 {9A183B48-ECC2-4121-876A-9B3793686073}.Debug|x64.Build.0 = Debug|x64 {9A183B48-ECC2-4121-876A-9B3793686073}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 @@ -295,6 +297,7 @@ Global {B7F1A9FB-BEA8-416E-9460-AE35A6A5165C}.Release|x64.ActiveCfg = Release|x64 {B7F1A9FB-BEA8-416E-9460-AE35A6A5165C}.Release|x64.Build.0 = Release|x64 {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Debug|Win32.ActiveCfg = Debug|Win32 + {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Debug|Win32.Build.0 = Debug|Win32 {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Debug|x64.ActiveCfg = Debug|x64 {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.Debug|x64.Build.0 = Debug|x64 {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 @@ -374,6 +377,7 @@ Global {E5D1F0C0-AA07-4841-A4EB-4CF4DAA6B0FA}.Release|x64.ActiveCfg = Release|x64 {E5D1F0C0-AA07-4841-A4EB-4CF4DAA6B0FA}.Release|x64.Build.0 = Release|x64 {521498BE-6089-4780-8223-E67C22F4E068}.Debug|Win32.ActiveCfg = Debug|Win32 + {521498BE-6089-4780-8223-E67C22F4E068}.Debug|Win32.Build.0 = Debug|Win32 {521498BE-6089-4780-8223-E67C22F4E068}.Debug|x64.ActiveCfg = Debug|x64 {521498BE-6089-4780-8223-E67C22F4E068}.Debug|x64.Build.0 = Debug|x64 {521498BE-6089-4780-8223-E67C22F4E068}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 @@ -421,6 +425,7 @@ Global {33546D62-7F34-4EA6-A88E-D538B36E16BF}.Release|x64.ActiveCfg = Release|x64 {33546D62-7F34-4EA6-A88E-D538B36E16BF}.Release|x64.Build.0 = Release|x64 {8D612734-FAA5-4B8A-804F-4DEA2367D495}.Debug|Win32.ActiveCfg = Debug|Win32 + {8D612734-FAA5-4B8A-804F-4DEA2367D495}.Debug|Win32.Build.0 = Debug|Win32 {8D612734-FAA5-4B8A-804F-4DEA2367D495}.Debug|x64.ActiveCfg = Debug|x64 {8D612734-FAA5-4B8A-804F-4DEA2367D495}.Debug|x64.Build.0 = Debug|x64 {8D612734-FAA5-4B8A-804F-4DEA2367D495}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 @@ -452,6 +457,7 @@ Global {C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Release|x64.ActiveCfg = Release|x64 {C7E5D50A-2916-464B-86A7-E10B3CC88ADA}.Release|x64.Build.0 = Release|x64 {58E81545-241B-416E-8088-E62452EB25FA}.Debug|Win32.ActiveCfg = Debug|Win32 + {58E81545-241B-416E-8088-E62452EB25FA}.Debug|Win32.Build.0 = Debug|Win32 {58E81545-241B-416E-8088-E62452EB25FA}.Debug|x64.ActiveCfg = Debug|x64 {58E81545-241B-416E-8088-E62452EB25FA}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 {58E81545-241B-416E-8088-E62452EB25FA}.DebugFast|x64.ActiveCfg = DebugFast|x64 @@ -476,6 +482,7 @@ Global {FBAFB369-07EB-4460-9CAD-08BE5789DAB6}.Release|x64.ActiveCfg = Release|x64 {FBAFB369-07EB-4460-9CAD-08BE5789DAB6}.Release|x64.Build.0 = Release|x64 {3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.Debug|Win32.ActiveCfg = Debug|Win32 + {3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.Debug|Win32.Build.0 = Debug|Win32 {3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.Debug|x64.ActiveCfg = Debug|x64 {3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.Debug|x64.Build.0 = Debug|x64 {3D8156A9-64D1-4C8E-ADBE-1B319030E4A4}.DebugFast|Win32.ActiveCfg = DebugFast|Win32 @@ -562,9 +569,7 @@ Global {823DDC98-42D5-4A38-88CF-9DC06C788AE4}.Release|x64.ActiveCfg = Release|x64 {823DDC98-42D5-4A38-88CF-9DC06C788AE4}.Release|x64.Build.0 = Release|x64 {40C636FA-B5BF-4D67-ABC8-376B524A7551}.Debug|Win32.ActiveCfg = Debug|Win32 - {40C636FA-B5BF-4D67-ABC8-376B524A7551}.Debug|Win32.Build.0 = Debug|Win32 {40C636FA-B5BF-4D67-ABC8-376B524A7551}.Debug|x64.ActiveCfg = Debug|x64 - {40C636FA-B5BF-4D67-ABC8-376B524A7551}.Debug|x64.Build.0 = Debug|x64 {40C636FA-B5BF-4D67-ABC8-376B524A7551}.DebugFast|Win32.ActiveCfg = Debug|Win32 {40C636FA-B5BF-4D67-ABC8-376B524A7551}.DebugFast|Win32.Build.0 = Debug|Win32 {40C636FA-B5BF-4D67-ABC8-376B524A7551}.DebugFast|x64.ActiveCfg = Debug|x64 diff --git a/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj b/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj index 32f8ca81e9..6bad245a5c 100644 --- a/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj +++ b/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj @@ -1,7 +1,7 @@ + + + + + + diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp index e816ac310b..634665cebd 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DBase.cpp @@ -228,12 +228,12 @@ namespace D3D adapter, D3DDEVTYPE_HAL, wnd, - D3DCREATE_HARDWARE_VERTEXPROCESSING, + D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, // |D3DCREATE_MULTITHREADED /* | D3DCREATE_PUREDEVICE*/, //D3DCREATE_SOFTWARE_VERTEXPROCESSING , &d3dpp, &dev ) ) ) { - MessageBox(wnd, + MessageBoxA(wnd, "Sorry, but it looks like your 3D accelerator is too old,\n" "or doesn't support features that Dolphin requires.\n" "Falling back to software vertex processing.\n", @@ -242,12 +242,12 @@ namespace D3D adapter, D3DDEVTYPE_HAL, wnd, - D3DCREATE_SOFTWARE_VERTEXPROCESSING, + D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED, // |D3DCREATE_MULTITHREADED /* | D3DCREATE_PUREDEVICE*/, //D3DCREATE_SOFTWARE_VERTEXPROCESSING , &d3dpp, &dev ) ) ) { - MessageBox(wnd, + MessageBoxA(wnd, "Software VP failed too. Upgrade your graphics card.", "Dolphin Direct3D plugin", MB_OK | MB_ICONERROR); return E_FAIL; @@ -263,7 +263,7 @@ namespace D3D if (caps.NumSimultaneousRTs < 2) { - MessageBox(0, "Warning - your graphics card does not support multiple render targets.", 0, 0); + MessageBoxA(0, "Warning - your graphics card does not support multiple render targets.", 0, 0); } // Device state would normally be set here @@ -309,19 +309,19 @@ namespace D3D switch (err) { case D3DERR_DEVICELOST: - MessageBox(0, "Device Lost", "D3D ERROR", 0); + MessageBoxA(0, "Device Lost", "D3D ERROR", 0); break; case D3DERR_INVALIDCALL: - MessageBox(0, "Invalid Call", "D3D ERROR", 0); + MessageBoxA(0, "Invalid Call", "D3D ERROR", 0); break; case D3DERR_DRIVERINTERNALERROR: - MessageBox(0, "Driver Internal Error", "D3D ERROR", 0); + MessageBoxA(0, "Driver Internal Error", "D3D ERROR", 0); break; case D3DERR_OUTOFVIDEOMEMORY: - MessageBox(0, "Out of vid mem", "D3D ERROR", 0); + MessageBoxA(0, "Out of vid mem", "D3D ERROR", 0); break; default: - // MessageBox(0,"Other error or success","ERROR",0); + // MessageBoxA(0,"Other error or success","ERROR",0); break; } } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.cpp index b3d550610b..3b0fa5478a 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DShader.cpp @@ -45,7 +45,7 @@ LPDIRECT3DVERTEXSHADER9 CompileVertexShader(const char *code, int len) std::string hello = (char*)errorBuffer->GetBufferPointer(); hello += "\n\n"; hello += code; - MessageBox(0, hello.c_str(), "Error assembling vertex shader", MB_ICONERROR); + MessageBoxA(0, hello.c_str(), "Error assembling vertex shader", MB_ICONERROR); } vShader = 0; } @@ -57,7 +57,7 @@ LPDIRECT3DVERTEXSHADER9 CompileVertexShader(const char *code, int len) hr = D3D::dev->CreateVertexShader((DWORD *)shaderBuffer->GetBufferPointer(), &vShader); if ((FAILED(hr) || vShader == 0) && g_Config.bShowShaderErrors) { - MessageBox(0, code, (char*)errorBuffer->GetBufferPointer(),MB_ICONERROR); + MessageBoxA(0, code, (char*)errorBuffer->GetBufferPointer(),MB_ICONERROR); } } @@ -89,7 +89,7 @@ LPDIRECT3DPIXELSHADER9 CompilePixelShader(const char *code, int len) std::string hello = (char*)errorBuffer->GetBufferPointer(); hello += "\n\n"; hello += code; - MessageBox(0, hello.c_str(), "Error assembling pixel shader", MB_ICONERROR); + MessageBoxA(0, hello.c_str(), "Error assembling pixel shader", MB_ICONERROR); } pShader = 0; } @@ -99,7 +99,7 @@ LPDIRECT3DPIXELSHADER9 CompilePixelShader(const char *code, int len) HRESULT hr = D3D::dev->CreatePixelShader((DWORD *)shaderBuffer->GetBufferPointer(), &pShader); if ((FAILED(hr) || pShader == 0) && g_Config.bShowShaderErrors) { - MessageBox(0, "damn", "error creating pixelshader", MB_ICONERROR); + MessageBoxA(0, "damn", "error creating pixelshader", MB_ICONERROR); } } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp index 988a3c74b7..347624bd51 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/D3DUtil.cpp @@ -83,7 +83,7 @@ namespace D3D HFONT hFont = CreateFont(nHeight, 0, 0, 0, dwBold, 0, FALSE, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, ANTIALIASED_QUALITY, - VARIABLE_PITCH, "Tahoma"); + VARIABLE_PITCH, _T("Tahoma")); if (NULL == hFont) return E_FAIL; @@ -106,7 +106,7 @@ namespace D3D for (char c=0; c<127-32; c++) { str[0] = c+32; - GetTextExtentPoint32(hDC, str, 1, &size); + GetTextExtentPoint32A(hDC, str, 1, &size); if ((int)(x+size.cx+1) > m_dwTexWidth) { @@ -114,7 +114,7 @@ namespace D3D y += size.cy+1; } - ExtTextOut(hDC, x+1, y+0, ETO_OPAQUE | ETO_CLIPPED, NULL, str, 1, NULL); + ExtTextOutA(hDC, x+1, y+0, ETO_OPAQUE | ETO_CLIPPED, NULL, str, 1, NULL); m_fTexCoords[c][0] = ((float)(x+0))/m_dwTexWidth; m_fTexCoords[c][1] = ((float)(y+0))/m_dwTexHeight; @@ -215,8 +215,9 @@ namespace D3D dev->SetPixelShader(0); dev->SetVertexShader(0); - // dev->SetVertexDeclaration(0); + dev->SetVertexDeclaration(0); + // dev->SetFVF(D3DFVF_FONT2DVERTEX); Renderer::SetFVF(D3DFVF_FONT2DVERTEX); for (int i = 0; i < 6; i++) { @@ -379,8 +380,9 @@ namespace D3D {x2-0.5f, y2-0.5f, 0, 1, color, u2, v2}, {x1-0.5f, y2-0.5f, 0, 1, color, u1, v2}, }; - dev->SetPixelShader(NULL); - dev->SetVertexShader(NULL); + dev->SetPixelShader(0); + dev->SetVertexShader(0); + dev->SetVertexDeclaration(0); Renderer::SetFVF(D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1); dev->DrawPrimitiveUP(D3DPT_TRIANGLEFAN, 2, coords, sizeof(Q2DVertex)); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Debugger/Debugger.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Debugger/Debugger.cpp new file mode 100644 index 0000000000..7dbcf4c2b8 --- /dev/null +++ b/Source/Plugins/Plugin_VideoDX9/Src/Debugger/Debugger.cpp @@ -0,0 +1,310 @@ +// Copyright (C) 2003 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + + +#include "IniFile.h" +#include "Debugger.h" + +#include "../Config.h" +#include "../Globals.h" +#include "../main.h" + +extern int g_Preset; + +BEGIN_EVENT_TABLE(GFXDebuggerDX9,wxDialog) + EVT_CLOSE(GFXDebuggerDX9::OnClose) + EVT_CHECKBOX(ID_SAVETOFILE,GFXDebuggerDX9::GeneralSettings) + EVT_CHECKBOX(ID_INFOLOG,GFXDebuggerDX9::GeneralSettings) + EVT_CHECKBOX(ID_PRIMLOG,GFXDebuggerDX9::GeneralSettings) + EVT_CHECKBOX(ID_SAVETEXTURES,GFXDebuggerDX9::GeneralSettings) + EVT_CHECKBOX(ID_SAVETARGETS,GFXDebuggerDX9::GeneralSettings) + EVT_CHECKBOX(ID_SAVESHADERS,GFXDebuggerDX9::GeneralSettings) + EVT_BUTTON(ID_PAUSE,GFXDebuggerDX9::OnPauseButton) + EVT_BUTTON(ID_PAUSE_AT_NEXT,GFXDebuggerDX9::OnPauseAtNextButton) + EVT_BUTTON(ID_GO,GFXDebuggerDX9::OnGoButton) + EVT_BUTTON(ID_DUMP,GFXDebuggerDX9::OnDumpButton) + EVT_BUTTON(ID_UPDATE_SCREEN,GFXDebuggerDX9::OnUpdateScreenButton) + EVT_BUTTON(ID_CLEAR_SCREEN,GFXDebuggerDX9::OnClearScreenButton) +END_EVENT_TABLE() + +GFXDebuggerDX9::GFXDebuggerDX9(wxWindow *parent, wxWindowID id, const wxString &title, + const wxPoint &position, const wxSize& size, long style) + : wxDialog(parent, id, title, position, size, style) +{ + CreateGUIControls(); + + LoadSettings(); +} + +GFXDebuggerDX9::~GFXDebuggerDX9() +{ + SaveSettings(); +} + +void GFXDebuggerDX9::OnClose(wxCloseEvent& event) +{ + // save the window position when we hide the window + SaveSettings(); + + event.Skip(); // This means wxDialog's Destroy is used +} + +void GFXDebuggerDX9::SaveSettings() const +{ + IniFile file; + file.Load(DEBUGGER_CONFIG_FILE); + + // TODO: make this work when we close the entire program too, currently on total close we get + // weird values, perhaps because of some conflict with the rendering window + // TODO: get the screen resolution and make limits from that + if (GetPosition().x < 1000 && GetPosition().y < 1000 + && GetSize().GetWidth() < 1000 + && GetSize().GetHeight() < 1000) + { + file.Set("VideoWindow", "x", GetPosition().x); + file.Set("VideoWindow", "y", GetPosition().y); + file.Set("VideoWindow", "w", GetSize().GetWidth()); + file.Set("VideoWindow", "h", GetSize().GetHeight()); + } + + file.Set("VideoWindow", "WriteToFile", m_Check[0]->IsChecked()); + + //g_Config.iLog = bInfoLog ? CONF_LOG : 0; + //g_Config.iLog |= bPrimLog ? CONF_PRIMLOG : 0; + //g_Config.iLog |= bSaveTextures ? CONF_SAVETEXTURES : 0; + //g_Config.iLog |= bSaveTargets ? CONF_SAVETARGETS : 0; + //g_Config.iLog |= bSaveShaders ? CONF_SAVESHADERS : 0; + + //file.Set("VideoWindow", "ConfBits", g_Config.iLog); + + file.Save(DEBUGGER_CONFIG_FILE); +} + +void GFXDebuggerDX9::LoadSettings() +{ + IniFile file; + file.Load(DEBUGGER_CONFIG_FILE); + + int x = 100, y = 100, w = 100, h = 100; + file.Get("VideoWindow", "x", &x, GetPosition().x); + file.Get("VideoWindow", "y", &y, GetPosition().y); + file.Get("VideoWindow", "w", &w, GetSize().GetWidth()); + file.Get("VideoWindow", "h", &h, GetSize().GetHeight()); + SetSize(x, y, w, h); + + //file.Get("VideoWindow", "ConfBits", &g_Config.iLog, 0); + //bInfoLog = (g_Config.iLog & CONF_LOG) ? true : false; + //bPrimLog = (g_Config.iLog & CONF_PRIMLOG) ? true : false; + //bSaveTextures = (g_Config.iLog & CONF_SAVETEXTURES) ? true : false; + //bSaveTargets = (g_Config.iLog & CONF_SAVETARGETS) ? true : false; + //bSaveShaders = (g_Config.iLog & CONF_SAVESHADERS) ? true : false; + //m_Check[1]->SetValue(bInfoLog); + //m_Check[2]->SetValue(bPrimLog); + //m_Check[3]->SetValue(bSaveTextures); + //m_Check[4]->SetValue(bSaveTargets); + //m_Check[5]->SetValue(bSaveShaders); +} + +void GFXDebuggerDX9::CreateGUIControls() +{ + // Basic settings + SetIcon(wxNullIcon); + CenterOnParent(); + + // MainPanel + m_MainPanel = new wxPanel(this, ID_MAINPANEL, wxDefaultPosition, wxDefaultSize); + + // Options + wxStaticBoxSizer *sOptions = new wxStaticBoxSizer(wxVERTICAL, m_MainPanel, wxT("Options")); + m_Check[0] = new wxCheckBox(m_MainPanel, ID_SAVETOFILE, wxT("Save to file"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_Check[1] = new wxCheckBox(m_MainPanel, ID_INFOLOG, wxT("Info log"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_Check[2] = new wxCheckBox(m_MainPanel, ID_PRIMLOG, wxT("Primary log"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_Check[3] = new wxCheckBox(m_MainPanel, ID_SAVETEXTURES, wxT("Save Textures"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_Check[4] = new wxCheckBox(m_MainPanel, ID_SAVETARGETS, wxT("Save Targets"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + m_Check[5] = new wxCheckBox(m_MainPanel, ID_SAVESHADERS, wxT("Save Shaders"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + + 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_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")); + m_pPauseAtList->SetSelection(0); + + m_pButtonDump = new wxButton(m_MainPanel, ID_DUMP, wxT("Dump"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("Dump")); + m_pButtonUpdateScreen = new wxButton(m_MainPanel, ID_UPDATE_SCREEN, wxT("Update Screen"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("Update Screen")); + m_pButtonClearScreen = new wxButton(m_MainPanel, ID_CLEAR_SCREEN, wxT("Clear Screen"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("Clear Screen")); + m_pCount = new wxTextCtrl(m_MainPanel, ID_COUNT, wxT("1"), wxDefaultPosition, wxSize(50,25), 0, wxDefaultValidator, wxT("Count")); + + m_pDumpList = new wxChoice(m_MainPanel, ID_DUMP_LIST, wxDefaultPosition, wxSize(120,25), 0, NULL,0,wxDefaultValidator, wxT("DumpList")); + m_pDumpList->Insert(wxT("Pixel Shader"),0); + m_pDumpList->Append(wxT("Vertex Shader")); + m_pDumpList->Append(wxT("Pixel Shader Constants")); + m_pDumpList->Append(wxT("Vertex Shader Constants")); + m_pDumpList->Append(wxT("Texture 0")); + m_pDumpList->Append(wxT("Texture 1")); + m_pDumpList->Append(wxT("Texture 2")); + m_pDumpList->Append(wxT("Texture 3")); + m_pDumpList->Append(wxT("Texture 4")); + m_pDumpList->Append(wxT("Texture 5")); + m_pDumpList->Append(wxT("Texture 6")); + m_pDumpList->Append(wxT("Texture 8")); + m_pDumpList->Append(wxT("Frame Buffer")); + m_pDumpList->Append(wxT("Vertices")); + m_pDumpList->Append(wxT("Vertex Description")); + m_pDumpList->Append(wxT("Vertex Matrices")); + m_pDumpList->Append(wxT("Statistics")); + m_pDumpList->SetSelection(0); + + for (int i = 0; i < NUM_OPTIONS-ID_SAVETOFILE; ++i) + sOptions->Add(m_Check[i], 0, 0, 5); + + // Layout everything on m_MainPanel + wxBoxSizer *sMain = new wxBoxSizer(wxVERTICAL); + + sMain->Add(sOptions); + sMain->Add(m_pButtonPause, 0, 0, 5); + sMain->Add(m_pButtonPauseAtNext, 0, 0, 5); + sMain->Add(m_pCount,0,0,5); + sMain->Add(m_pPauseAtList, 0, 0, 5); + sMain->Add(m_pButtonDump, 0, 0, 5); + sMain->Add(m_pDumpList, 0, 0, 5); + sMain->Add(m_pButtonUpdateScreen, 0, 0, 5); + sMain->Add(m_pButtonClearScreen, 0, 0, 5); + sMain->Add(m_pButtonGo, 0, 0, 5); + m_MainPanel->SetSizerAndFit(sMain); + Fit(); +} + +// General settings +void GFXDebuggerDX9::GeneralSettings(wxCommandEvent& event) +{ + switch (event.GetId()) + { + case ID_INFOLOG: + bInfoLog = event.IsChecked(); + break; + case ID_PRIMLOG: + bPrimLog = event.IsChecked(); + break; + case ID_SAVETEXTURES: + bSaveTextures = event.IsChecked(); + break; + case ID_SAVETARGETS: + bSaveTargets = event.IsChecked(); + break; + case ID_SAVESHADERS: + bSaveShaders = event.IsChecked(); + break; + } + SaveSettings(); +} + +volatile bool DX9DebuggerPauseFlag = false; +volatile PauseEvent DX9DebuggerToPauseAtNext = NOT_PAUSE; +volatile int DX9DebuggerEventToPauseCount = 0; + +void GFXDebuggerDX9::OnPauseButton(wxCommandEvent& event) +{ + DX9DebuggerPauseFlag = true; +} + +void GFXDebuggerDX9::OnPauseAtNextButton(wxCommandEvent& event) +{ + DX9DebuggerPauseFlag = false; + DX9DebuggerToPauseAtNext = (PauseEvent)(m_pPauseAtList->GetSelection()); + wxString val = m_pCount->GetValue(); + long value; + if (val.ToLong(&value) ) + DX9DebuggerEventToPauseCount = PauseEvent(value); + else + DX9DebuggerEventToPauseCount = 1; +} + +void GFXDebuggerDX9::OnDumpButton(wxCommandEvent& event) +{ +} + +void GFXDebuggerDX9::OnGoButton(wxCommandEvent& event) +{ + DX9DebuggerToPauseAtNext = NOT_PAUSE; + DX9DebuggerPauseFlag = false; +} + +void GFXDebuggerDX9::OnUpdateScreenButton(wxCommandEvent& event) +{ +} +void GFXDebuggerDX9::OnClearScreenButton(wxCommandEvent& event) +{ +} + +void UpdateFPSDisplay(const char *text); +void DX9DebuggerCheckAndPause() +{ + while( DX9DebuggerPauseFlag ) + { + UpdateFPSDisplay("Paused by Video Debugger"); + Sleep(5); + } +} + +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(false); + } + DX9DebuggerCheckAndPause(); + } + } +} + +#endif ENABLE_DX_DEBUGGER + + diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Debugger/Debugger.h b/Source/Plugins/Plugin_VideoDX9/Src/Debugger/Debugger.h new file mode 100644 index 0000000000..09ec7cf39d --- /dev/null +++ b/Source/Plugins/Plugin_VideoDX9/Src/Debugger/Debugger.h @@ -0,0 +1,243 @@ +// Copyright (C) 2003 Dolphin Project. + +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 2.0. + +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License 2.0 for more details. + +// A copy of the GPL 2.0 should have been included with the program. +// If not, see http://www.gnu.org/licenses/ + +// Official SVN repository and contact information can be found at +// http://code.google.com/p/dolphin-emu/ + +#ifndef _DX_DEBUGGER_H_ +#define _DX_DEBUGGER_H_ + +#include +#include + +#include "../Globals.h" + +class IniFile; + +class GFXDebuggerDX9 : public wxDialog +{ +public: + GFXDebuggerDX9(wxWindow *parent, + wxWindowID id = 1, + const wxString &title = wxT("Video"), + const wxPoint& pos = wxDefaultPosition, + const wxSize& size = wxDefaultSize, + #ifdef _WIN32 + long style = wxNO_BORDER); + #else + long style = wxDEFAULT_FRAME_STYLE | wxCLIP_CHILDREN | wxNO_FULL_REPAINT_ON_RESIZE); + #endif + + virtual ~GFXDebuggerDX9(); + + void SaveSettings() const; + void LoadSettings(); + + bool bInfoLog; + bool bPrimLog; + bool bSaveTextures; + bool bSaveTargets; + bool bSaveShaders; + +private: + DECLARE_EVENT_TABLE(); + + wxPanel *m_MainPanel; + + wxCheckBox *m_Check[6]; + wxButton *m_pButtonPause; + wxButton *m_pButtonPauseAtNext; + wxButton *m_pButtonGo; + wxChoice *m_pPauseAtList; + wxButton *m_pButtonDump; + wxChoice *m_pDumpList; + wxButton *m_pButtonUpdateScreen; + wxButton *m_pButtonClearScreen; + wxTextCtrl *m_pCount; + + + // WARNING: Make sure these are not also elsewhere + enum + { + ID_MAINPANEL = 3900, + ID_SAVETOFILE, + ID_INFOLOG, + ID_PRIMLOG, + ID_SAVETEXTURES, + ID_SAVETARGETS, + ID_SAVESHADERS, + NUM_OPTIONS, + ID_GO, + ID_PAUSE, + ID_PAUSE_AT_NEXT, + ID_PAUSE_AT_LIST, + ID_DUMP, + ID_DUMP_LIST, + ID_UPDATE_SCREEN, + ID_CLEAR_SCREEN, + ID_COUNT + }; + + void OnClose(wxCloseEvent& event); + void CreateGUIControls(); + + void GeneralSettings(wxCommandEvent& event); + void OnPauseButton(wxCommandEvent& event); + void OnPauseAtNextButton(wxCommandEvent& event); + void OnDumpButton(wxCommandEvent& event); + void OnGoButton(wxCommandEvent& event); + void OnUpdateScreenButton(wxCommandEvent& event); + void OnClearScreenButton(wxCommandEvent& event); + void OnCountEnter(wxCommandEvent& event); +}; + +enum PauseEvent { + NEXT_FRAME, + NEXT_FLUSH, + NEXT_FIFO, + NEXT_DLIST, + NEXT_PIXEL_SHADER_CHANGE, + NEXT_VERTEX_SHADER_CHANGE, + NEXT_NEW_TEXTURE, + NEXT_RENDER_TEXTURE, + NEXT_MATRIX_CMD, + NEXT_VERTEX_CMD, + NEXT_TEXTURE_CMD, + NEXT_LIGHT_CMD, + NEXT_FRAME_BUFFER_CMD, + NEXT_FOG_CMD, + NEXT_SET_CONSTANT_COLOR, + NEXT_UCODE, + NEXT_SET_TEXTURE, + NEXT_SET_LIGHT, + NEXT_SET_MODE_CMD, + NEXT_UNKNOWN_OP, + NEXT_LOADTLUT, + NEXT_SWITCH_UCODE, + NOT_PAUSE, +}; + +extern volatile bool DX9DebuggerPauseFlag; +extern volatile PauseEvent DX9DebuggerToPauseAtNext; +extern volatile int DX9DebuggerEventToPauseCount; +void ContinueDX9Debugger(); +void DX9DebuggerCheckAndPause(); + +#undef ENABLE_DX_DEBUGGER +#ifdef _DEBUG +#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} } + +#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) {} + +#endif ENABLE_DX_DEBUGGER + + +#endif // _DX_DEBUGGER_H_ diff --git a/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp b/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp index 44b7f90915..6d0300d3be 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/DlgSettings.cpp @@ -43,10 +43,13 @@ struct TabDirect3D : public W32Util::Tab { void Init(HWND hDlg) { + WCHAR tempwstr[2000]; + for (int i=0; iSetPixelShader(entry.shader); last_shader = entry.shader; + DEBUGGER_PAUSE_COUNT_N(NEXT_PIXEL_SHADER_CHANGE); } return; } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index 58fc3c0ba4..d06b26f2a6 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -39,6 +39,8 @@ #include "EmuWindow.h" #include "AVIDump.h" +#include "debugger/debugger.h" + float Renderer::m_x; float Renderer::m_y; float Renderer::m_width; @@ -326,6 +328,9 @@ void Renderer::SwapBuffers() #endif D3D::EndFrame(); + + DEBUGGER_PAUSE_COUNT_N_WITHOUT_UPDATE(NEXT_FRAME); + //D3D frame is now over ////////////////////////////////////////////////////////////////////////// diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp index bcb951cc55..3199b33cdc 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureCache.cpp @@ -82,7 +82,7 @@ void TextureCache::Cleanup() while(iter != textures.end()) { - if (frameCount > TEXTURE_KILL_THRESHOLD + iter->second.frameCount) + if (frameCount> TEXTURE_KILL_THRESHOLD + iter->second.frameCount) { if (!iter->second.isRenderTarget) { @@ -105,20 +105,23 @@ void TextureCache::Cleanup() TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width, int height, int format, int tlutaddr, int tlutfmt) { - if (address == 0) return NULL; + + if (address == 0) + return NULL; TexCache::iterator iter = textures.find(address); + u8 *ptr = g_VideoInitialize.pGetMemoryPointer(address); + int palSize = TexDecoder_GetPaletteSize(format); u32 palhash = 0xc0debabe; if (palSize) { - // TODO: Share this code with the GL plugin. - if (palSize > 32) - palSize = 32; // let's not do excessive amount of checking + if (palSize>16) + palSize = 16; //let's not do excessive amount of checking u8 *pal = g_VideoInitialize.pGetMemoryPointer(tlutaddr); if (pal != 0) { - for (int i = 0; i < palSize; i++) + for (int i=0; isecond; @@ -170,7 +174,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width, } } - PC_TexFormat pcfmt = TexDecoder_Decode(temp, ptr, expandedWidth, height, format, tlutaddr, tlutfmt); + PC_TexFormat pcfmt = TexDecoder_Decode(temp,ptr,expandedWidth,height,format, tlutaddr, tlutfmt); D3DFORMAT d3d_fmt; switch (pcfmt) { case PC_TEX_FMT_BGRA32: @@ -180,7 +184,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width, d3d_fmt = D3DFMT_R5G6B5; break; case PC_TEX_FMT_IA4_AS_IA8: - d3d_fmt = D3DFMT_A8L8; //D3DFMT_A4L4; + d3d_fmt = D3DFMT_A4L4; break; case PC_TEX_FMT_I8: case PC_TEX_FMT_I4_AS_I8: @@ -232,7 +236,7 @@ TextureCache::TCacheEntry *TextureCache::Load(int stage, u32 address, int width, sprintf(szTemp, "%s/%s_%08x_%i.png",szDir, ((struct SConfig *)globals->config)->m_LocalCoreStartupParameter.GetUniqueID().c_str(), hash_value, format); //sprintf(szTemp, "%s\\txt_%04i_%i.png", g_Config.texDumpPath.c_str(), counter++, format); <-- Old method if (!File::Exists(szTemp)) - D3DXSaveTextureToFile(szTemp,D3DXIFF_BMP,entry.texture,0); + D3DXSaveTextureToFileA(szTemp,D3DXIFF_BMP,entry.texture,0); } INCSTAT(stats.numTexturesCreated); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp index ddae369406..697dd2ef10 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexManager.cpp @@ -16,7 +16,6 @@ // http://code.google.com/p/dolphin-emu/ #include "Common.h" -#include "FileUtil.h" #include "D3DBase.h" @@ -37,6 +36,9 @@ #include "BPStructs.h" #include "XFStructs.h" +#include "debugger/debugger.h" + + using namespace D3D; // internal state for loading vertices @@ -82,8 +84,6 @@ bool Init() collection = C_NOTHING; fakeVBuffer = new u8[MAXVBUFFERSIZE]; fakeIBuffer = new u16[MAXIBUFFERSIZE]; - memset(fakeVBuffer, 0, MAXVBUFFERSIZE); - memset(fakeIBuffer, 0, MAXIBUFFERSIZE * 2); CreateDeviceObjects(); VertexManager::s_pCurBufferPointer = fakeVBuffer; return true; @@ -146,6 +146,9 @@ void AddVertices(int _primitive, int _numVertices) //We are NOT collecting the right type. Flush(); + // Copy the extra verts that we lost. + memcpy(s_pCurBufferPointer, fakeVBuffer, _numVertices * g_nativeVertexFmt->GetVertexStride()); + collection = type; u16 *ptr = 0; if (type != C_POINTS) @@ -155,7 +158,7 @@ void AddVertices(int _primitive, int _numVertices) AddIndices(_primitive, _numVertices); } if (_numVertices >= MAXVBUFFERSIZE) - MessageBox(NULL, "Too many vertices for the buffer", "Dolphin DX9 Video Plugin", MB_OK); + MessageBoxA(NULL, "Too many vertices for the buffer", "Dolphin DX9 Video Plugin", MB_OK); } else // We are collecting the right type, keep going { @@ -165,7 +168,7 @@ void AddVertices(int _primitive, int _numVertices) int last = indexGen.GetNumVerts(); AddIndices(_primitive, _numVertices); if (_numVertices >= MAXVBUFFERSIZE) - MessageBox(NULL, "Too many vertices for the buffer", "Dolphin DX9 Video Plugin", MB_OK); + MessageBoxA(NULL, "Too many vertices for the buffer", "Dolphin DX9 Video Plugin", MB_OK); } } @@ -321,7 +324,9 @@ void Flush() collection = C_NOTHING; VertexManager::s_pCurBufferPointer = fakeVBuffer; + DEBUGGER_PAUSE_COUNT_N(NEXT_FLUSH); } + //DX9DEBUGGER_PAUSE_IF(NEXT_FLUSH); } } // namespace diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp index 023094d7e4..186cb757d3 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp @@ -28,6 +28,8 @@ #include "BPMemory.h" #include "XFMemory.h" +#include "debugger/debugger.h" + VertexShaderCache::VSCache VertexShaderCache::vshaders; const VertexShaderCache::VSCacheEntry *VertexShaderCache::last_entry; @@ -76,6 +78,8 @@ void VertexShaderCache::SetShader(u32 components) { D3D::dev->SetVertexShader(entry.shader); last_shader = entry.shader; + + DEBUGGER_PAUSE_COUNT_N(NEXT_VERTEX_SHADER_CHANGE); } return; } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/W32Util/File.cpp b/Source/Plugins/Plugin_VideoDX9/Src/W32Util/File.cpp index f17278e4f6..6f66de795d 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/W32Util/File.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/W32Util/File.cpp @@ -104,7 +104,7 @@ namespace W32Util mojs[4]=0; *(int*)mojs=cookie; sprintf(temp,"W32Util::File: Magic Cookie %s is bad!",mojs); - MessageBox(0,temp,"Error reading file",MB_ICONERROR); + MessageBoxA(0,temp,"Error reading file",MB_ICONERROR); return false; } else diff --git a/Source/Plugins/Plugin_VideoDX9/Src/W32Util/Misc.cpp b/Source/Plugins/Plugin_VideoDX9/Src/W32Util/Misc.cpp index 2f3a88b5ba..254c552767 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/W32Util/Misc.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/W32Util/Misc.cpp @@ -82,7 +82,7 @@ namespace W32Util { OpenClipboard(hwnd); EmptyClipboard(); - HANDLE hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (strlen(text) + 1) * sizeof(TCHAR)); + HANDLE hglbCopy = GlobalAlloc(GMEM_MOVEABLE, (wcslen(text) + 1) * sizeof(TCHAR)); if (hglbCopy == NULL) { CloseClipboard(); @@ -92,8 +92,8 @@ namespace W32Util // Lock the handle and copy the text to the buffer. TCHAR *lptstrCopy = (TCHAR *)GlobalLock(hglbCopy); - strcpy(lptstrCopy, text); - lptstrCopy[strlen(text)] = (TCHAR) 0; // null character + wcscpy(lptstrCopy, text); + lptstrCopy[wcslen(text)] = (TCHAR) 0; // null character GlobalUnlock(hglbCopy); SetClipboardData(CF_TEXT,hglbCopy); CloseClipboard(); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/W32Util/Misc.h b/Source/Plugins/Plugin_VideoDX9/Src/W32Util/Misc.h index c5d6fc368d..a5a86a12bf 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/W32Util/Misc.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/W32Util/Misc.h @@ -4,6 +4,6 @@ namespace W32Util { void CenterWindow(HWND hwnd); HBITMAP CreateBitmapFromARGB(HWND someHwnd, DWORD *image, int w, int h); - void NiceSizeFormat(size_t size, char *out); - BOOL CopyTextToClipboard(HWND hwnd, TCHAR *text); + void NiceSizeFormat(size_t size, char * out); + BOOL CopyTextToClipboard(HWND hwnd, char * text); } \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX9/Src/W32Util/PropertySheet.cpp b/Source/Plugins/Plugin_VideoDX9/Src/W32Util/PropertySheet.cpp index 95cbe3c3f5..58678dc8e8 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/W32Util/PropertySheet.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/W32Util/PropertySheet.cpp @@ -60,7 +60,7 @@ namespace W32Util return 0; } - void PropSheet::Show(HINSTANCE hInstance, HWND hParent, std::string title, int startpage, bool floating, bool wizard) + void PropSheet::Show(HINSTANCE hInstance, HWND hParent, LPCTSTR title, int startpage, bool floating, bool wizard) { HPROPSHEETPAGE *pages = new HPROPSHEETPAGE[list.size()]; PROPSHEETPAGE page; @@ -118,7 +118,7 @@ namespace W32Util if (icon) sheet.dwFlags |= PSH_USEHICON; - sheet.pszCaption = title.c_str(); + sheet.pszCaption = title; sheet.nPages = (UINT)list.size(); sheet.phpage = pages; sheet.nStartPage = startpage; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/W32Util/PropertySheet.h b/Source/Plugins/Plugin_VideoDX9/Src/W32Util/PropertySheet.h index 1080d21afb..59df901cd3 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/W32Util/PropertySheet.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/W32Util/PropertySheet.h @@ -75,7 +75,7 @@ namespace W32Util void SetHeader(LPCTSTR _header) {header=_header;} void SetIcon(HICON _icon) {icon = _icon;} void Add(Tab *tab, LPCTSTR resource, LPCTSTR title, LPCTSTR subtitle = 0); - void Show(HINSTANCE hInstance, HWND hParent, std::string title, int startpage=0, bool floating = false, bool wizard = false); + void Show(HINSTANCE hInstance, HWND hParent, LPCTSTR title, int startpage=0, bool floating = false, bool wizard = false); HFONT GetTitleFont() {return hTitleFont;} HFONT GetFont() {return hDialogFont;} static int CALLBACK Callback(HWND hwndDlg, UINT uMsg, LPARAM lParam); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/W32Util/ShellUtil.cpp b/Source/Plugins/Plugin_VideoDX9/Src/W32Util/ShellUtil.cpp index 2de6b8aa80..ec98ae7d26 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/W32Util/ShellUtil.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/W32Util/ShellUtil.cpp @@ -8,17 +8,17 @@ namespace W32Util { std::string BrowseForFolder(HWND parent, char *title) { - BROWSEINFO info; + BROWSEINFOA info; memset(&info,0,sizeof(info)); info.hwndOwner = parent; info.lpszTitle = title; info.ulFlags = BIF_EDITBOX | BIF_RETURNONLYFSDIRS; //info.pszDisplayName - LPCITEMIDLIST idList = SHBrowseForFolder(&info); + LPCITEMIDLIST idList = SHBrowseForFolderA(&info); char temp[MAX_PATH]; - SHGetPathFromIDList(idList, temp); + SHGetPathFromIDListA(idList, temp); if (strlen(temp)) { return temp; @@ -37,7 +37,7 @@ namespace W32Util char szFile [MAX_PATH+1] = {0}; char szFileTitle [MAX_PATH+1] = {0}; - OPENFILENAME ofn; + OPENFILENAMEA ofn; ZeroMemory (&ofn,sizeof (ofn)); ofn.lStructSize = sizeof (OPENFILENAME); ofn.lpstrInitialDir = _pInitialFolder; @@ -53,7 +53,7 @@ namespace W32Util if (_strFileName.size () != 0) ofn.lpstrFile = (char *)_strFileName.c_str(); - if (((_bLoad) ? GetOpenFileName(&ofn) : GetSaveFileName(&ofn))) + if (((_bLoad) ? GetOpenFileNameA(&ofn) : GetSaveFileNameA(&ofn))) { _strFileName = ofn.lpstrFile; return true; @@ -70,7 +70,7 @@ namespace W32Util strcpy (szFile,""); strcpy (szFileTitle,""); - OPENFILENAME ofn; + OPENFILENAMEA ofn; ZeroMemory (&ofn,sizeof (ofn)); @@ -87,7 +87,7 @@ namespace W32Util std::vector files; - if (((_bLoad)?GetOpenFileName (&ofn):GetSaveFileName (&ofn))) + if (((_bLoad)?GetOpenFileNameA (&ofn):GetSaveFileNameA (&ofn))) { std::string directory = ofn.lpstrFile; char *temp = ofn.lpstrFile; diff --git a/Source/Plugins/Plugin_VideoDX9/Src/W32Util/TabControl.cpp b/Source/Plugins/Plugin_VideoDX9/Src/W32Util/TabControl.cpp index fef2fcc7fb..f674267574 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/W32Util/TabControl.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/W32Util/TabControl.cpp @@ -27,7 +27,7 @@ namespace W32Util // HWND TabControl::AddItem (char* _szText,int _iResource,DLGPROC _lpDialogFunc) { - TCITEM tcItem; + TCITEMA tcItem; ZeroMemory (&tcItem,sizeof (tcItem)); @@ -40,7 +40,7 @@ namespace W32Util int nResult = TabCtrl_InsertItem (m_hTabCtrl,TabCtrl_GetItemCount (m_hTabCtrl),&tcItem); - HWND hDialog = CreateDialog(m_hInstance,(LPCSTR)_iResource,m_hTabCtrl,_lpDialogFunc); + HWND hDialog = CreateDialogA(m_hInstance,(LPCSTR)_iResource,m_hTabCtrl,_lpDialogFunc); RECT rectInnerWindow = {0,0,0,0}; GetWindowRect (m_hTabCtrl,&rectInnerWindow); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp index fa8c597630..77145c4e59 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp @@ -23,6 +23,12 @@ #include "Thread.h" #include "LogManager.h" + +#if defined(HAVE_WX) && HAVE_WX +#include "Debugger/Debugger.h" +GFXDebuggerDX9 *m_DebuggerFrame = NULL; +#endif // HAVE_WX + #include "svnrev.h" #include "resource.h" #include "main.h" @@ -62,10 +68,58 @@ bool HandleDisplayList(u32 address, u32 size) { return false; } + +// This is used for the functions right below here which use wxwidgets +#if defined(HAVE_WX) && HAVE_WX +#ifdef _WIN32 + WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); +#endif + +wxWindow* GetParentedWxWindow(HWND Parent) +{ +#ifdef _WIN32 + wxSetInstance((HINSTANCE)g_hInstance); +#endif + wxWindow *win = new wxWindow(); +#ifdef _WIN32 + win->SetHWND((WXHWND)Parent); + win->AdoptAttributesFromHWND(); +#endif + return win; +} +#endif + +#if defined(HAVE_WX) && HAVE_WX void DllDebugger(HWND _hParent, bool Show) { - // TODO: implement + //SetWindowTextA(EmuWindow::GetWnd(), "Hello"); + + if (!m_DebuggerFrame) + m_DebuggerFrame = new GFXDebuggerDX9(GetParentedWxWindow(_hParent)); + + if (Show) + m_DebuggerFrame->Show(); + else + m_DebuggerFrame->Hide(); } +#else +void DllDebugger(HWND _hParent, bool Show) { } +#endif + + + +#if defined(HAVE_WX) && HAVE_WX + class wxDLLApp : public wxApp + { + bool OnInit() + { + return true; + } + }; + IMPLEMENT_APP_NO_MAIN(wxDLLApp) + WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); +#endif + BOOL APIENTRY DllMain( HINSTANCE hinstDLL, // DLL module handle @@ -75,8 +129,24 @@ BOOL APIENTRY DllMain( HINSTANCE hinstDLL, // DLL module handle switch (dwReason) { case DLL_PROCESS_ATTACH: + { + #if defined(HAVE_WX) && HAVE_WX + // Use wxInitialize() if you don't want GUI instead of the following 12 lines + wxSetInstance((HINSTANCE)hinstDLL); + int argc = 0; + char **argv = NULL; + wxEntryStart(argc, argv); + if (!wxTheApp || !wxTheApp->CallOnInit()) + return FALSE; + #endif + } break; case DLL_PROCESS_DETACH: + #if defined(HAVE_WX) && HAVE_WX + // This causes a "stop hang", if the gfx config dialog has been opened. + // Old comment: "Use wxUninitialize() if you don't want GUI" + wxEntryCleanup(); + #endif break; default: break; @@ -105,7 +175,7 @@ void UpdateFPSDisplay(const char *text) { char temp[512]; sprintf_s(temp, 512, "SVN R%i: DX9: %s", SVN_REV, text); - SetWindowText(EmuWindow::GetWnd(), temp); + SetWindowTextA(EmuWindow::GetWnd(), temp); } @@ -118,16 +188,16 @@ bool Init() // create the window if (!g_Config.renderToMainframe || g_VideoInitialize.pWindowHandle == NULL) // ignore parent for this plugin { - g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create(NULL, g_hInstance, "Loading - Please wait."); + g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create(NULL, g_hInstance, _T("Loading - Please wait.")); } else { - g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, "Loading - Please wait."); + g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, _T("Loading - Please wait.")); } if (g_VideoInitialize.pWindowHandle == NULL) { - MessageBox(GetActiveWindow(), "An error has occurred while trying to create the window.", "Fatal Error", MB_OK); + MessageBox(GetActiveWindow(), _T("An error has occurred while trying to create the window."), _T("Fatal Error"), MB_OK); return false; } @@ -137,7 +207,7 @@ bool Init() if (FAILED(D3D::Init())) { - MessageBox(GetActiveWindow(), "Unable to initialize Direct3D. Please make sure that you have DirectX 9.0c correctly installed.", "Fatal Error", MB_OK); + MessageBox(GetActiveWindow(), _T("Unable to initialize Direct3D. Please make sure that you have DirectX 9.0c correctly installed."), _T("Fatal Error"), MB_OK); return false; } InitXFBConvTables(); @@ -179,7 +249,7 @@ void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) { void DllAbout(HWND _hParent) { - DialogBox(g_hInstance,(LPCSTR)IDD_ABOUT,_hParent,(DLGPROC)AboutProc); + DialogBoxA(g_hInstance,(LPCSTR)IDD_ABOUT,_hParent,(DLGPROC)AboutProc); } void DllConfig(HWND _hParent) @@ -323,7 +393,7 @@ HRESULT ScreenShot(const char *File) RECT rect; ::GetWindowRect(EmuWindow::GetWnd(), &rect); - if (FAILED(D3DXSaveSurfaceToFile(File, D3DXIFF_PNG, surf, NULL, &rect))) + if (FAILED(D3DXSaveSurfaceToFileA(File, D3DXIFF_PNG, surf, NULL, &rect))) { surf->Release(); return S_FALSE; diff --git a/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcproj b/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcproj index 13dfe14026..09bd3880b3 100644 --- a/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcproj +++ b/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcproj @@ -1,7 +1,7 @@ @@ -379,7 +379,7 @@ ProgramDataBaseFileName="$(IntDir)\" WarningLevel="3" SuppressStartupBanner="true" - DebugInformationFormat="3" + DebugInformationFormat="4" CompileAs="0" ForcedIncludeFiles="stdafx.h" /> @@ -618,7 +618,7 @@ OutputFile="..\..\..\Binary\x64\Plugins\Plugin_VideoOGLDF.dll" LinkIncremental="1" SuppressStartupBanner="true" - AdditionalLibraryDirectories="..\..\..\Externals\Cg64;..\..\..\Externals\GLew;..\..\..\Externals\libjpeg;..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)" + AdditionalLibraryDirectories="..\..\..\Externals\Cg64;..\..\..\Externals\GLew;..\..\..\Externals\libjpeg;"..\..\..\Externals\wxWidgets\lib\vc_lib\$(PlatformName)"" GenerateManifest="false" GenerateDebugInformation="true" ProgramDatabaseFile="$(PlatformName)\$(ConfigurationName)\$(TargetName).pdb"