mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
Hg:
enable newline normalization get revision number via `hg svn info` for svnrev.h ignore incremental/generated binary files (windows/VS at least) leave a comment if some files need native eol set in svnprops git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5637 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -1,408 +1,408 @@
|
||||
// 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 "FileUtil.h"
|
||||
|
||||
#include "VideoConfig.h"
|
||||
#include "../Globals.h"
|
||||
#include "../D3DBase.h"
|
||||
#include "../FramebufferManager.h"
|
||||
#include "../TextureCache.h"
|
||||
#include "../VertexShaderCache.h"
|
||||
#include "../PixelShaderCache.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_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)
|
||||
EVT_BUTTON(ID_CLEAR_SCREEN,GFXDebuggerDX9::OnClearScreenButton)
|
||||
EVT_BUTTON(ID_CLEAR_TEXTURE_CACHE,GFXDebuggerDX9::OnClearTextureCacheButton)
|
||||
EVT_BUTTON(ID_CLEAR_VERTEX_SHADER_CACHE,GFXDebuggerDX9::OnClearVertexShaderCacheButton)
|
||||
EVT_BUTTON(ID_CLEAR_PIXEL_SHADER_CACHE,GFXDebuggerDX9::OnClearPixelShaderCacheButton)
|
||||
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(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
|
||||
// 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(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::LoadSettings()
|
||||
{
|
||||
IniFile file;
|
||||
file.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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_ERROR, wxT("Error")}
|
||||
};
|
||||
static const int numPauseEventMap = sizeof(pauseEventMap)/sizeof(PauseEventMap);
|
||||
|
||||
|
||||
static GFXDebuggerDX9 *g_pdebugger = NULL;
|
||||
|
||||
void GFXDebuggerDX9::CreateGUIControls()
|
||||
{
|
||||
g_pdebugger = this;
|
||||
|
||||
// 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_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"));
|
||||
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"));
|
||||
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_pButtonClearTextureCache = new wxButton(m_MainPanel, ID_CLEAR_TEXTURE_CACHE, wxT("Clear Textures"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("Clear Textures"));
|
||||
m_pButtonClearVertexShaderCache = new wxButton(m_MainPanel, ID_CLEAR_VERTEX_SHADER_CACHE, wxT("Clear V Shaders"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("Clear V Shaders"));
|
||||
m_pButtonClearPixelShaderCache = new wxButton(m_MainPanel, ID_CLEAR_PIXEL_SHADER_CACHE, wxT("Clear P Shaders"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("Clear P Shaders"));
|
||||
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_pButtonClearTextureCache, 0, 0, 5);
|
||||
sMain->Add(m_pButtonClearVertexShaderCache, 0, 0, 5);
|
||||
sMain->Add(m_pButtonClearPixelShaderCache, 0, 0, 5);
|
||||
sMain->Add(m_pButtonPauseAtNextFrame, 0, 0, 5);
|
||||
sMain->Add(m_pButtonGo, 0, 0, 5);
|
||||
m_MainPanel->SetSizerAndFit(sMain);
|
||||
Fit();
|
||||
|
||||
EnableButtons(false);
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::EnableButtons(bool enable)
|
||||
{
|
||||
m_pButtonDump->Enable(enable);
|
||||
m_pButtonUpdateScreen->Enable(enable);
|
||||
m_pButtonClearScreen->Enable(enable);
|
||||
m_pButtonClearTextureCache->Enable(enable);
|
||||
m_pButtonClearVertexShaderCache->Enable(enable);
|
||||
m_pButtonClearPixelShaderCache->Enable(enable);
|
||||
}
|
||||
|
||||
|
||||
// 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 = pauseEventMap[m_pPauseAtList->GetSelection()].event;
|
||||
wxString val = m_pCount->GetValue();
|
||||
long value;
|
||||
if (val.ToLong(&value) )
|
||||
DX9DebuggerEventToPauseCount = value;
|
||||
else
|
||||
DX9DebuggerEventToPauseCount = 1;
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnPauseAtNextFrameButton(wxCommandEvent& event)
|
||||
{
|
||||
DX9DebuggerPauseFlag = false;
|
||||
DX9DebuggerToPauseAtNext = NEXT_FRAME;
|
||||
DX9DebuggerEventToPauseCount = 1;
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnDumpButton(wxCommandEvent& event)
|
||||
{
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnGoButton(wxCommandEvent& event)
|
||||
{
|
||||
DX9DebuggerToPauseAtNext = NOT_PAUSE;
|
||||
DX9DebuggerPauseFlag = false;
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnClearScreenButton(wxCommandEvent& event)
|
||||
{
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnClearTextureCacheButton(wxCommandEvent& event)
|
||||
{
|
||||
TextureCache::Invalidate(false);
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnClearVertexShaderCacheButton(wxCommandEvent& event)
|
||||
{
|
||||
VertexShaderCache::Clear();
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnClearPixelShaderCacheButton(wxCommandEvent& event)
|
||||
{
|
||||
PixelShaderCache::Clear();
|
||||
}
|
||||
|
||||
void UpdateFPSDisplay(const char *text);
|
||||
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)
|
||||
{
|
||||
if (DX9DebuggerPauseFlag)
|
||||
{
|
||||
g_pdebugger->EnableButtons(true);
|
||||
while( DX9DebuggerPauseFlag )
|
||||
{
|
||||
|
||||
UpdateFPSDisplay("Paused by Video Debugger");
|
||||
|
||||
if (update) DX9DebuggerUpdateScreen();
|
||||
Sleep(5);
|
||||
}
|
||||
g_pdebugger->EnableButtons(false);
|
||||
}
|
||||
}
|
||||
|
||||
void DX9DebuggerToPause(bool update)
|
||||
{
|
||||
DX9DebuggerToPauseAtNext = NOT_PAUSE;
|
||||
DX9DebuggerPauseFlag = true;
|
||||
DX9DebuggerCheckAndPause(update);
|
||||
}
|
||||
|
||||
|
||||
void ContinueDX9Debugger()
|
||||
{
|
||||
DX9DebuggerPauseFlag = false;
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnUpdateScreenButton(wxCommandEvent& event)
|
||||
{
|
||||
DX9DebuggerUpdateScreen();
|
||||
}
|
||||
// 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 "FileUtil.h"
|
||||
|
||||
#include "VideoConfig.h"
|
||||
#include "../Globals.h"
|
||||
#include "../D3DBase.h"
|
||||
#include "../FramebufferManager.h"
|
||||
#include "../TextureCache.h"
|
||||
#include "../VertexShaderCache.h"
|
||||
#include "../PixelShaderCache.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_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)
|
||||
EVT_BUTTON(ID_CLEAR_SCREEN,GFXDebuggerDX9::OnClearScreenButton)
|
||||
EVT_BUTTON(ID_CLEAR_TEXTURE_CACHE,GFXDebuggerDX9::OnClearTextureCacheButton)
|
||||
EVT_BUTTON(ID_CLEAR_VERTEX_SHADER_CACHE,GFXDebuggerDX9::OnClearVertexShaderCacheButton)
|
||||
EVT_BUTTON(ID_CLEAR_PIXEL_SHADER_CACHE,GFXDebuggerDX9::OnClearPixelShaderCacheButton)
|
||||
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(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
|
||||
// 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(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::LoadSettings()
|
||||
{
|
||||
IniFile file;
|
||||
file.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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_ERROR, wxT("Error")}
|
||||
};
|
||||
static const int numPauseEventMap = sizeof(pauseEventMap)/sizeof(PauseEventMap);
|
||||
|
||||
|
||||
static GFXDebuggerDX9 *g_pdebugger = NULL;
|
||||
|
||||
void GFXDebuggerDX9::CreateGUIControls()
|
||||
{
|
||||
g_pdebugger = this;
|
||||
|
||||
// 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_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"));
|
||||
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"));
|
||||
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_pButtonClearTextureCache = new wxButton(m_MainPanel, ID_CLEAR_TEXTURE_CACHE, wxT("Clear Textures"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("Clear Textures"));
|
||||
m_pButtonClearVertexShaderCache = new wxButton(m_MainPanel, ID_CLEAR_VERTEX_SHADER_CACHE, wxT("Clear V Shaders"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("Clear V Shaders"));
|
||||
m_pButtonClearPixelShaderCache = new wxButton(m_MainPanel, ID_CLEAR_PIXEL_SHADER_CACHE, wxT("Clear P Shaders"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxT("Clear P Shaders"));
|
||||
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_pButtonClearTextureCache, 0, 0, 5);
|
||||
sMain->Add(m_pButtonClearVertexShaderCache, 0, 0, 5);
|
||||
sMain->Add(m_pButtonClearPixelShaderCache, 0, 0, 5);
|
||||
sMain->Add(m_pButtonPauseAtNextFrame, 0, 0, 5);
|
||||
sMain->Add(m_pButtonGo, 0, 0, 5);
|
||||
m_MainPanel->SetSizerAndFit(sMain);
|
||||
Fit();
|
||||
|
||||
EnableButtons(false);
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::EnableButtons(bool enable)
|
||||
{
|
||||
m_pButtonDump->Enable(enable);
|
||||
m_pButtonUpdateScreen->Enable(enable);
|
||||
m_pButtonClearScreen->Enable(enable);
|
||||
m_pButtonClearTextureCache->Enable(enable);
|
||||
m_pButtonClearVertexShaderCache->Enable(enable);
|
||||
m_pButtonClearPixelShaderCache->Enable(enable);
|
||||
}
|
||||
|
||||
|
||||
// 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 = pauseEventMap[m_pPauseAtList->GetSelection()].event;
|
||||
wxString val = m_pCount->GetValue();
|
||||
long value;
|
||||
if (val.ToLong(&value) )
|
||||
DX9DebuggerEventToPauseCount = value;
|
||||
else
|
||||
DX9DebuggerEventToPauseCount = 1;
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnPauseAtNextFrameButton(wxCommandEvent& event)
|
||||
{
|
||||
DX9DebuggerPauseFlag = false;
|
||||
DX9DebuggerToPauseAtNext = NEXT_FRAME;
|
||||
DX9DebuggerEventToPauseCount = 1;
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnDumpButton(wxCommandEvent& event)
|
||||
{
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnGoButton(wxCommandEvent& event)
|
||||
{
|
||||
DX9DebuggerToPauseAtNext = NOT_PAUSE;
|
||||
DX9DebuggerPauseFlag = false;
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnClearScreenButton(wxCommandEvent& event)
|
||||
{
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnClearTextureCacheButton(wxCommandEvent& event)
|
||||
{
|
||||
TextureCache::Invalidate(false);
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnClearVertexShaderCacheButton(wxCommandEvent& event)
|
||||
{
|
||||
VertexShaderCache::Clear();
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnClearPixelShaderCacheButton(wxCommandEvent& event)
|
||||
{
|
||||
PixelShaderCache::Clear();
|
||||
}
|
||||
|
||||
void UpdateFPSDisplay(const char *text);
|
||||
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)
|
||||
{
|
||||
if (DX9DebuggerPauseFlag)
|
||||
{
|
||||
g_pdebugger->EnableButtons(true);
|
||||
while( DX9DebuggerPauseFlag )
|
||||
{
|
||||
|
||||
UpdateFPSDisplay("Paused by Video Debugger");
|
||||
|
||||
if (update) DX9DebuggerUpdateScreen();
|
||||
Sleep(5);
|
||||
}
|
||||
g_pdebugger->EnableButtons(false);
|
||||
}
|
||||
}
|
||||
|
||||
void DX9DebuggerToPause(bool update)
|
||||
{
|
||||
DX9DebuggerToPauseAtNext = NOT_PAUSE;
|
||||
DX9DebuggerPauseFlag = true;
|
||||
DX9DebuggerCheckAndPause(update);
|
||||
}
|
||||
|
||||
|
||||
void ContinueDX9Debugger()
|
||||
{
|
||||
DX9DebuggerPauseFlag = false;
|
||||
}
|
||||
|
||||
void GFXDebuggerDX9::OnUpdateScreenButton(wxCommandEvent& event)
|
||||
{
|
||||
DX9DebuggerUpdateScreen();
|
||||
}
|
||||
|
@ -1,171 +1,171 @@
|
||||
// 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 <wx/wx.h>
|
||||
#include <wx/notebook.h>
|
||||
|
||||
#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;
|
||||
|
||||
void EnableButtons(bool enable);
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
wxPanel *m_MainPanel;
|
||||
|
||||
wxCheckBox *m_Check[6];
|
||||
wxButton *m_pButtonPause;
|
||||
wxButton *m_pButtonPauseAtNext;
|
||||
wxButton *m_pButtonPauseAtNextFrame;
|
||||
wxButton *m_pButtonGo;
|
||||
wxChoice *m_pPauseAtList;
|
||||
wxButton *m_pButtonDump;
|
||||
wxChoice *m_pDumpList;
|
||||
wxButton *m_pButtonUpdateScreen;
|
||||
wxButton *m_pButtonClearScreen;
|
||||
wxButton *m_pButtonClearTextureCache;
|
||||
wxButton *m_pButtonClearVertexShaderCache;
|
||||
wxButton *m_pButtonClearPixelShaderCache;
|
||||
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_NEXT_FRAME,
|
||||
ID_PAUSE_AT_LIST,
|
||||
ID_DUMP,
|
||||
ID_DUMP_LIST,
|
||||
ID_UPDATE_SCREEN,
|
||||
ID_CLEAR_SCREEN,
|
||||
ID_CLEAR_TEXTURE_CACHE,
|
||||
ID_CLEAR_VERTEX_SHADER_CACHE,
|
||||
ID_CLEAR_PIXEL_SHADER_CACHE,
|
||||
ID_COUNT
|
||||
};
|
||||
|
||||
void OnClose(wxCloseEvent& event);
|
||||
void CreateGUIControls();
|
||||
|
||||
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);
|
||||
void OnClearScreenButton(wxCommandEvent& event);
|
||||
void OnClearTextureCacheButton(wxCommandEvent& event);
|
||||
void OnClearVertexShaderCacheButton(wxCommandEvent& event);
|
||||
void OnClearPixelShaderCacheButton(wxCommandEvent& event);
|
||||
void OnCountEnter(wxCommandEvent& event);
|
||||
|
||||
};
|
||||
|
||||
enum PauseEvent {
|
||||
NOT_PAUSE = 0,
|
||||
NEXT_FRAME = 1<<0,
|
||||
NEXT_FLUSH = 1<<1,
|
||||
|
||||
NEXT_PIXEL_SHADER_CHANGE = 1<<2,
|
||||
NEXT_VERTEX_SHADER_CHANGE = 1<<3,
|
||||
NEXT_TEXTURE_CHANGE = 1<<4,
|
||||
NEXT_NEW_TEXTURE = 1<<5,
|
||||
|
||||
NEXT_XFB_CMD = 1<<6,
|
||||
NEXT_EFB_CMD = 1<<7,
|
||||
|
||||
NEXT_MATRIX_CMD = 1<<8,
|
||||
NEXT_VERTEX_CMD = 1<<9,
|
||||
NEXT_TEXTURE_CMD = 1<<10,
|
||||
NEXT_LIGHT_CMD = 1<<11,
|
||||
NEXT_FOG_CMD = 1<<12,
|
||||
|
||||
NEXT_SET_TLUT = 1<<13,
|
||||
|
||||
NEXT_ERROR = 1<<14,
|
||||
};
|
||||
|
||||
extern volatile bool DX9DebuggerPauseFlag;
|
||||
extern volatile PauseEvent DX9DebuggerToPauseAtNext;
|
||||
extern volatile int DX9DebuggerEventToPauseCount;
|
||||
void ContinueDX9Debugger();
|
||||
void DX9DebuggerCheckAndPause(bool update);
|
||||
void DX9DebuggerToPause(bool update);
|
||||
|
||||
#undef ENABLE_DX_DEBUGGER
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
#define ENABLE_DX_DEBUGGER
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_DX_DEBUGGER
|
||||
|
||||
#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);}}
|
||||
#define DEBUGGER_LOG_AT(event,dumpfunc) {if (( DX9DebuggerToPauseAtNext & event ) ) {{dumpfunc};}}
|
||||
|
||||
#else
|
||||
// Not to use debugger in release build
|
||||
#define DEBUGGER_PAUSE_AT(event,update)
|
||||
#define DEBUGGER_PAUSE_LOG_AT(event,update,dumpfunc)
|
||||
#define DEBUGGER_LOG_AT(event,dumpfunc)
|
||||
|
||||
#endif ENABLE_DX_DEBUGGER
|
||||
|
||||
|
||||
#endif // _DX_DEBUGGER_H_
|
||||
// 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 <wx/wx.h>
|
||||
#include <wx/notebook.h>
|
||||
|
||||
#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;
|
||||
|
||||
void EnableButtons(bool enable);
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
wxPanel *m_MainPanel;
|
||||
|
||||
wxCheckBox *m_Check[6];
|
||||
wxButton *m_pButtonPause;
|
||||
wxButton *m_pButtonPauseAtNext;
|
||||
wxButton *m_pButtonPauseAtNextFrame;
|
||||
wxButton *m_pButtonGo;
|
||||
wxChoice *m_pPauseAtList;
|
||||
wxButton *m_pButtonDump;
|
||||
wxChoice *m_pDumpList;
|
||||
wxButton *m_pButtonUpdateScreen;
|
||||
wxButton *m_pButtonClearScreen;
|
||||
wxButton *m_pButtonClearTextureCache;
|
||||
wxButton *m_pButtonClearVertexShaderCache;
|
||||
wxButton *m_pButtonClearPixelShaderCache;
|
||||
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_NEXT_FRAME,
|
||||
ID_PAUSE_AT_LIST,
|
||||
ID_DUMP,
|
||||
ID_DUMP_LIST,
|
||||
ID_UPDATE_SCREEN,
|
||||
ID_CLEAR_SCREEN,
|
||||
ID_CLEAR_TEXTURE_CACHE,
|
||||
ID_CLEAR_VERTEX_SHADER_CACHE,
|
||||
ID_CLEAR_PIXEL_SHADER_CACHE,
|
||||
ID_COUNT
|
||||
};
|
||||
|
||||
void OnClose(wxCloseEvent& event);
|
||||
void CreateGUIControls();
|
||||
|
||||
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);
|
||||
void OnClearScreenButton(wxCommandEvent& event);
|
||||
void OnClearTextureCacheButton(wxCommandEvent& event);
|
||||
void OnClearVertexShaderCacheButton(wxCommandEvent& event);
|
||||
void OnClearPixelShaderCacheButton(wxCommandEvent& event);
|
||||
void OnCountEnter(wxCommandEvent& event);
|
||||
|
||||
};
|
||||
|
||||
enum PauseEvent {
|
||||
NOT_PAUSE = 0,
|
||||
NEXT_FRAME = 1<<0,
|
||||
NEXT_FLUSH = 1<<1,
|
||||
|
||||
NEXT_PIXEL_SHADER_CHANGE = 1<<2,
|
||||
NEXT_VERTEX_SHADER_CHANGE = 1<<3,
|
||||
NEXT_TEXTURE_CHANGE = 1<<4,
|
||||
NEXT_NEW_TEXTURE = 1<<5,
|
||||
|
||||
NEXT_XFB_CMD = 1<<6,
|
||||
NEXT_EFB_CMD = 1<<7,
|
||||
|
||||
NEXT_MATRIX_CMD = 1<<8,
|
||||
NEXT_VERTEX_CMD = 1<<9,
|
||||
NEXT_TEXTURE_CMD = 1<<10,
|
||||
NEXT_LIGHT_CMD = 1<<11,
|
||||
NEXT_FOG_CMD = 1<<12,
|
||||
|
||||
NEXT_SET_TLUT = 1<<13,
|
||||
|
||||
NEXT_ERROR = 1<<14,
|
||||
};
|
||||
|
||||
extern volatile bool DX9DebuggerPauseFlag;
|
||||
extern volatile PauseEvent DX9DebuggerToPauseAtNext;
|
||||
extern volatile int DX9DebuggerEventToPauseCount;
|
||||
void ContinueDX9Debugger();
|
||||
void DX9DebuggerCheckAndPause(bool update);
|
||||
void DX9DebuggerToPause(bool update);
|
||||
|
||||
#undef ENABLE_DX_DEBUGGER
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
#define ENABLE_DX_DEBUGGER
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_DX_DEBUGGER
|
||||
|
||||
#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);}}
|
||||
#define DEBUGGER_LOG_AT(event,dumpfunc) {if (( DX9DebuggerToPauseAtNext & event ) ) {{dumpfunc};}}
|
||||
|
||||
#else
|
||||
// Not to use debugger in release build
|
||||
#define DEBUGGER_PAUSE_AT(event,update)
|
||||
#define DEBUGGER_PAUSE_LOG_AT(event,update,dumpfunc)
|
||||
#define DEBUGGER_LOG_AT(event,dumpfunc)
|
||||
|
||||
#endif ENABLE_DX_DEBUGGER
|
||||
|
||||
|
||||
#endif // _DX_DEBUGGER_H_
|
||||
|
@ -1,173 +1,173 @@
|
||||
// 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 _FRAMEBUFFERMANAGER_D3D_H_
|
||||
#define _FRAMEBUFFERMANAGER_D3D_H_
|
||||
|
||||
#include <list>
|
||||
#include "D3DBase.h"
|
||||
|
||||
// On the GameCube, the game sends a request for the graphics processor to
|
||||
// transfer its internal EFB (Embedded Framebuffer) to an area in GameCube RAM
|
||||
// called the XFB (External Framebuffer). The size and location of the XFB is
|
||||
// decided at the time of the copy, and the format is always YUYV. The video
|
||||
// interface is given a pointer to the XFB, which will be decoded and
|
||||
// displayed on the TV.
|
||||
//
|
||||
// There are two ways for Dolphin to emulate this:
|
||||
//
|
||||
// Real XFB mode:
|
||||
//
|
||||
// Dolphin will behave like the GameCube and encode the EFB to
|
||||
// a portion of GameCube RAM. The emulated video interface will decode the data
|
||||
// for output to the screen.
|
||||
//
|
||||
// Advantages: Behaves exactly like the GameCube.
|
||||
// Disadvantages: Resolution will be limited.
|
||||
//
|
||||
// Virtual XFB mode:
|
||||
//
|
||||
// When a request is made to copy the EFB to an XFB, Dolphin
|
||||
// will remember the RAM location and size of the XFB in a Virtual XFB list.
|
||||
// The video interface will look up the XFB in the list and use the enhanced
|
||||
// data stored there, if available.
|
||||
//
|
||||
// Advantages: Enables high resolution graphics, better than real hardware.
|
||||
// Disadvantages: If the GameCube CPU writes directly to the XFB (which is
|
||||
// possible but uncommon), the Virtual XFB will not capture this information.
|
||||
|
||||
// There may be multiple XFBs in GameCube RAM. This is the maximum number to
|
||||
// virtualize.
|
||||
const int MAX_VIRTUAL_XFB = 8;
|
||||
|
||||
inline bool addrRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper)
|
||||
{
|
||||
return !((aLower >= bUpper) || (bLower >= aUpper));
|
||||
}
|
||||
|
||||
struct XFBSource
|
||||
{
|
||||
XFBSource()
|
||||
{
|
||||
this->srcAddr = 0;
|
||||
this->srcWidth = 0;
|
||||
this->srcHeight = 0;
|
||||
this->texture = 0;
|
||||
this->texWidth = 0;
|
||||
this->texHeight = 0;
|
||||
}
|
||||
|
||||
u32 srcAddr;
|
||||
u32 srcWidth;
|
||||
u32 srcHeight;
|
||||
|
||||
LPDIRECT3DTEXTURE9 texture;
|
||||
int texWidth;
|
||||
int texHeight;
|
||||
};
|
||||
|
||||
class FramebufferManager
|
||||
{
|
||||
public:
|
||||
FramebufferManager()
|
||||
{
|
||||
s_efb_color_texture = NULL;
|
||||
LPDIRECT3DTEXTURE9 s_efb_colorRead_texture = NULL;
|
||||
LPDIRECT3DTEXTURE9 s_efb_depth_texture = NULL;
|
||||
LPDIRECT3DTEXTURE9 s_efb_depthRead_texture = NULL;
|
||||
|
||||
LPDIRECT3DSURFACE9 s_efb_depth_surface = NULL;
|
||||
LPDIRECT3DSURFACE9 s_efb_color_surface = NULL;
|
||||
LPDIRECT3DSURFACE9 s_efb_color_ReadBuffer = NULL;
|
||||
LPDIRECT3DSURFACE9 s_efb_depth_ReadBuffer = NULL;
|
||||
LPDIRECT3DSURFACE9 s_efb_color_OffScreenReadBuffer = NULL;
|
||||
LPDIRECT3DSURFACE9 s_efb_depth_OffScreenReadBuffer = NULL;
|
||||
|
||||
D3DFORMAT s_efb_color_surface_Format = D3DFMT_FORCE_DWORD;
|
||||
D3DFORMAT s_efb_depth_surface_Format = D3DFMT_FORCE_DWORD;
|
||||
D3DFORMAT s_efb_depth_ReadBuffer_Format = D3DFMT_FORCE_DWORD;
|
||||
m_realXFBSource.texture = NULL;
|
||||
}
|
||||
|
||||
void Create();
|
||||
void Destroy();
|
||||
|
||||
void CopyToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc);
|
||||
|
||||
const XFBSource** GetXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount);
|
||||
|
||||
LPDIRECT3DTEXTURE9 GetEFBColorTexture(const EFBRectangle& sourceRc);
|
||||
LPDIRECT3DTEXTURE9 GetEFBDepthTexture(const EFBRectangle& sourceRc);
|
||||
|
||||
LPDIRECT3DSURFACE9 GetEFBColorRTSurface();
|
||||
LPDIRECT3DSURFACE9 GetEFBDepthRTSurface();
|
||||
LPDIRECT3DSURFACE9 GetEFBColorOffScreenRTSurface();
|
||||
LPDIRECT3DSURFACE9 GetEFBDepthOffScreenRTSurface();
|
||||
D3DFORMAT GetEFBDepthRTSurfaceFormat();
|
||||
D3DFORMAT GetEFBColorRTSurfaceFormat();
|
||||
D3DFORMAT GetEFBDepthReadSurfaceFormat();
|
||||
LPDIRECT3DSURFACE9 GetEFBColorReadSurface();
|
||||
LPDIRECT3DSURFACE9 GetEFBDepthReadSurface();
|
||||
|
||||
private:
|
||||
|
||||
struct VirtualXFB
|
||||
{
|
||||
// Address and size in GameCube RAM
|
||||
u32 xfbAddr;
|
||||
u32 xfbWidth;
|
||||
u32 xfbHeight;
|
||||
|
||||
XFBSource xfbSource;
|
||||
};
|
||||
|
||||
typedef std::list<VirtualXFB> VirtualXFBListType;
|
||||
|
||||
VirtualXFBListType::iterator findVirtualXFB(u32 xfbAddr, u32 width, u32 height);
|
||||
|
||||
void replaceVirtualXFB();
|
||||
|
||||
void copyToRealXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc);
|
||||
void copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc);
|
||||
const XFBSource** getRealXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount);
|
||||
const XFBSource** getVirtualXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount);
|
||||
|
||||
XFBSource m_realXFBSource; // Only used in Real XFB mode
|
||||
VirtualXFBListType m_virtualXFBList; // Only used in Virtual XFB mode
|
||||
|
||||
const XFBSource* m_overlappingXFBArray[MAX_VIRTUAL_XFB];
|
||||
|
||||
LPDIRECT3DTEXTURE9 s_efb_color_texture;//Texture thats contains the color data of the render target
|
||||
LPDIRECT3DTEXTURE9 s_efb_colorRead_texture;//1 pixel texture for temporal data store
|
||||
LPDIRECT3DTEXTURE9 s_efb_depth_texture;//Texture thats contains the depth data of the render target
|
||||
LPDIRECT3DTEXTURE9 s_efb_depthRead_texture;//4 pixel texture for temporal data store
|
||||
|
||||
LPDIRECT3DSURFACE9 s_efb_depth_surface;//Depth Surface
|
||||
LPDIRECT3DSURFACE9 s_efb_color_surface;//Color Surface
|
||||
LPDIRECT3DSURFACE9 s_efb_color_ReadBuffer;//Surface 0 of s_efb_colorRead_texture
|
||||
LPDIRECT3DSURFACE9 s_efb_depth_ReadBuffer;//Surface 0 of s_efb_depthRead_texture
|
||||
LPDIRECT3DSURFACE9 s_efb_color_OffScreenReadBuffer;//System memory Surface that can be locked to retriebe the data
|
||||
LPDIRECT3DSURFACE9 s_efb_depth_OffScreenReadBuffer;//System memory Surface that can be locked to retriebe the data
|
||||
|
||||
D3DFORMAT s_efb_color_surface_Format;//Format of the color Surface
|
||||
D3DFORMAT s_efb_depth_surface_Format;//Format of the Depth Surface
|
||||
D3DFORMAT s_efb_depth_ReadBuffer_Format;//Format of the Depth color Read Surface
|
||||
};
|
||||
|
||||
extern FramebufferManager FBManager;
|
||||
|
||||
#endif
|
||||
// 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 _FRAMEBUFFERMANAGER_D3D_H_
|
||||
#define _FRAMEBUFFERMANAGER_D3D_H_
|
||||
|
||||
#include <list>
|
||||
#include "D3DBase.h"
|
||||
|
||||
// On the GameCube, the game sends a request for the graphics processor to
|
||||
// transfer its internal EFB (Embedded Framebuffer) to an area in GameCube RAM
|
||||
// called the XFB (External Framebuffer). The size and location of the XFB is
|
||||
// decided at the time of the copy, and the format is always YUYV. The video
|
||||
// interface is given a pointer to the XFB, which will be decoded and
|
||||
// displayed on the TV.
|
||||
//
|
||||
// There are two ways for Dolphin to emulate this:
|
||||
//
|
||||
// Real XFB mode:
|
||||
//
|
||||
// Dolphin will behave like the GameCube and encode the EFB to
|
||||
// a portion of GameCube RAM. The emulated video interface will decode the data
|
||||
// for output to the screen.
|
||||
//
|
||||
// Advantages: Behaves exactly like the GameCube.
|
||||
// Disadvantages: Resolution will be limited.
|
||||
//
|
||||
// Virtual XFB mode:
|
||||
//
|
||||
// When a request is made to copy the EFB to an XFB, Dolphin
|
||||
// will remember the RAM location and size of the XFB in a Virtual XFB list.
|
||||
// The video interface will look up the XFB in the list and use the enhanced
|
||||
// data stored there, if available.
|
||||
//
|
||||
// Advantages: Enables high resolution graphics, better than real hardware.
|
||||
// Disadvantages: If the GameCube CPU writes directly to the XFB (which is
|
||||
// possible but uncommon), the Virtual XFB will not capture this information.
|
||||
|
||||
// There may be multiple XFBs in GameCube RAM. This is the maximum number to
|
||||
// virtualize.
|
||||
const int MAX_VIRTUAL_XFB = 8;
|
||||
|
||||
inline bool addrRangesOverlap(u32 aLower, u32 aUpper, u32 bLower, u32 bUpper)
|
||||
{
|
||||
return !((aLower >= bUpper) || (bLower >= aUpper));
|
||||
}
|
||||
|
||||
struct XFBSource
|
||||
{
|
||||
XFBSource()
|
||||
{
|
||||
this->srcAddr = 0;
|
||||
this->srcWidth = 0;
|
||||
this->srcHeight = 0;
|
||||
this->texture = 0;
|
||||
this->texWidth = 0;
|
||||
this->texHeight = 0;
|
||||
}
|
||||
|
||||
u32 srcAddr;
|
||||
u32 srcWidth;
|
||||
u32 srcHeight;
|
||||
|
||||
LPDIRECT3DTEXTURE9 texture;
|
||||
int texWidth;
|
||||
int texHeight;
|
||||
};
|
||||
|
||||
class FramebufferManager
|
||||
{
|
||||
public:
|
||||
FramebufferManager()
|
||||
{
|
||||
s_efb_color_texture = NULL;
|
||||
LPDIRECT3DTEXTURE9 s_efb_colorRead_texture = NULL;
|
||||
LPDIRECT3DTEXTURE9 s_efb_depth_texture = NULL;
|
||||
LPDIRECT3DTEXTURE9 s_efb_depthRead_texture = NULL;
|
||||
|
||||
LPDIRECT3DSURFACE9 s_efb_depth_surface = NULL;
|
||||
LPDIRECT3DSURFACE9 s_efb_color_surface = NULL;
|
||||
LPDIRECT3DSURFACE9 s_efb_color_ReadBuffer = NULL;
|
||||
LPDIRECT3DSURFACE9 s_efb_depth_ReadBuffer = NULL;
|
||||
LPDIRECT3DSURFACE9 s_efb_color_OffScreenReadBuffer = NULL;
|
||||
LPDIRECT3DSURFACE9 s_efb_depth_OffScreenReadBuffer = NULL;
|
||||
|
||||
D3DFORMAT s_efb_color_surface_Format = D3DFMT_FORCE_DWORD;
|
||||
D3DFORMAT s_efb_depth_surface_Format = D3DFMT_FORCE_DWORD;
|
||||
D3DFORMAT s_efb_depth_ReadBuffer_Format = D3DFMT_FORCE_DWORD;
|
||||
m_realXFBSource.texture = NULL;
|
||||
}
|
||||
|
||||
void Create();
|
||||
void Destroy();
|
||||
|
||||
void CopyToXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc);
|
||||
|
||||
const XFBSource** GetXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount);
|
||||
|
||||
LPDIRECT3DTEXTURE9 GetEFBColorTexture(const EFBRectangle& sourceRc);
|
||||
LPDIRECT3DTEXTURE9 GetEFBDepthTexture(const EFBRectangle& sourceRc);
|
||||
|
||||
LPDIRECT3DSURFACE9 GetEFBColorRTSurface();
|
||||
LPDIRECT3DSURFACE9 GetEFBDepthRTSurface();
|
||||
LPDIRECT3DSURFACE9 GetEFBColorOffScreenRTSurface();
|
||||
LPDIRECT3DSURFACE9 GetEFBDepthOffScreenRTSurface();
|
||||
D3DFORMAT GetEFBDepthRTSurfaceFormat();
|
||||
D3DFORMAT GetEFBColorRTSurfaceFormat();
|
||||
D3DFORMAT GetEFBDepthReadSurfaceFormat();
|
||||
LPDIRECT3DSURFACE9 GetEFBColorReadSurface();
|
||||
LPDIRECT3DSURFACE9 GetEFBDepthReadSurface();
|
||||
|
||||
private:
|
||||
|
||||
struct VirtualXFB
|
||||
{
|
||||
// Address and size in GameCube RAM
|
||||
u32 xfbAddr;
|
||||
u32 xfbWidth;
|
||||
u32 xfbHeight;
|
||||
|
||||
XFBSource xfbSource;
|
||||
};
|
||||
|
||||
typedef std::list<VirtualXFB> VirtualXFBListType;
|
||||
|
||||
VirtualXFBListType::iterator findVirtualXFB(u32 xfbAddr, u32 width, u32 height);
|
||||
|
||||
void replaceVirtualXFB();
|
||||
|
||||
void copyToRealXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc);
|
||||
void copyToVirtualXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc);
|
||||
const XFBSource** getRealXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount);
|
||||
const XFBSource** getVirtualXFBSource(u32 xfbAddr, u32 fbWidth, u32 fbHeight, u32 &xfbCount);
|
||||
|
||||
XFBSource m_realXFBSource; // Only used in Real XFB mode
|
||||
VirtualXFBListType m_virtualXFBList; // Only used in Virtual XFB mode
|
||||
|
||||
const XFBSource* m_overlappingXFBArray[MAX_VIRTUAL_XFB];
|
||||
|
||||
LPDIRECT3DTEXTURE9 s_efb_color_texture;//Texture thats contains the color data of the render target
|
||||
LPDIRECT3DTEXTURE9 s_efb_colorRead_texture;//1 pixel texture for temporal data store
|
||||
LPDIRECT3DTEXTURE9 s_efb_depth_texture;//Texture thats contains the depth data of the render target
|
||||
LPDIRECT3DTEXTURE9 s_efb_depthRead_texture;//4 pixel texture for temporal data store
|
||||
|
||||
LPDIRECT3DSURFACE9 s_efb_depth_surface;//Depth Surface
|
||||
LPDIRECT3DSURFACE9 s_efb_color_surface;//Color Surface
|
||||
LPDIRECT3DSURFACE9 s_efb_color_ReadBuffer;//Surface 0 of s_efb_colorRead_texture
|
||||
LPDIRECT3DSURFACE9 s_efb_depth_ReadBuffer;//Surface 0 of s_efb_depthRead_texture
|
||||
LPDIRECT3DSURFACE9 s_efb_color_OffScreenReadBuffer;//System memory Surface that can be locked to retriebe the data
|
||||
LPDIRECT3DSURFACE9 s_efb_depth_OffScreenReadBuffer;//System memory Surface that can be locked to retriebe the data
|
||||
|
||||
D3DFORMAT s_efb_color_surface_Format;//Format of the color Surface
|
||||
D3DFORMAT s_efb_depth_surface_Format;//Format of the Depth Surface
|
||||
D3DFORMAT s_efb_depth_ReadBuffer_Format;//Format of the Depth color Read Surface
|
||||
};
|
||||
|
||||
extern FramebufferManager FBManager;
|
||||
|
||||
#endif
|
||||
|
@ -1,31 +1,31 @@
|
||||
// Copyright (C) 2003-2009 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 _GLOBALS_H_
|
||||
#define _GLOBALS_H_
|
||||
|
||||
#include "Common.h"
|
||||
#include "VideoConfig.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "VideoCommon.h"
|
||||
#include "pluginspecs_video.h"
|
||||
|
||||
// A global plugin specification
|
||||
extern PLUGIN_GLOBALS* globals;
|
||||
|
||||
#endif // _GLOBALS_H_
|
||||
// Copyright (C) 2003-2009 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 _GLOBALS_H_
|
||||
#define _GLOBALS_H_
|
||||
|
||||
#include "Common.h"
|
||||
#include "VideoConfig.h"
|
||||
#include "main.h"
|
||||
|
||||
#include "VideoCommon.h"
|
||||
#include "pluginspecs_video.h"
|
||||
|
||||
// A global plugin specification
|
||||
extern PLUGIN_GLOBALS* globals;
|
||||
|
||||
#endif // _GLOBALS_H_
|
||||
|
@ -1,481 +1,481 @@
|
||||
// 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/
|
||||
|
||||
// Fast image conversion using OpenGL shaders.
|
||||
// This kind of stuff would be a LOT nicer with OpenCL.
|
||||
|
||||
#include "TextureConverter.h"
|
||||
#include "TextureConversionShader.h"
|
||||
#include "PixelShaderCache.h"
|
||||
#include "VertexShaderManager.h"
|
||||
#include "VertexShaderCache.h"
|
||||
#include "FramebufferManager.h"
|
||||
#include "Globals.h"
|
||||
#include "VideoConfig.h"
|
||||
#include "ImageWrite.h"
|
||||
#include "Render.h"
|
||||
#include "TextureCache.h"
|
||||
#include "Math.h"
|
||||
#include "FileUtil.h"
|
||||
|
||||
namespace TextureConverter
|
||||
{
|
||||
struct TransformBuffer
|
||||
{
|
||||
LPDIRECT3DTEXTURE9 FBTexture;
|
||||
LPDIRECT3DSURFACE9 RenderSurface;
|
||||
LPDIRECT3DSURFACE9 ReadSurface;
|
||||
int Width;
|
||||
int Height;
|
||||
};
|
||||
const u32 NUM_TRANSFORM_BUFFERS = 16;
|
||||
static TransformBuffer TrnBuffers[NUM_TRANSFORM_BUFFERS];
|
||||
static u32 WorkingBuffers = 0;
|
||||
|
||||
static LPDIRECT3DPIXELSHADER9 s_rgbToYuyvProgram = NULL;
|
||||
static LPDIRECT3DPIXELSHADER9 s_yuyvToRgbProgram = NULL;
|
||||
|
||||
// Not all slots are taken - but who cares.
|
||||
const u32 NUM_ENCODING_PROGRAMS = 64;
|
||||
static LPDIRECT3DPIXELSHADER9 s_encodingPrograms[NUM_ENCODING_PROGRAMS];
|
||||
|
||||
void CreateRgbToYuyvProgram()
|
||||
{
|
||||
// Output is BGRA because that is slightly faster than RGBA.
|
||||
char* FProgram = new char[2048];
|
||||
sprintf(FProgram,"uniform float4 blkDims : register(c%d);\n"
|
||||
"uniform float4 textureDims : register(c%d);\n"
|
||||
"uniform sampler samp0 : register(s0);\n"
|
||||
"void main(\n"
|
||||
" out float4 ocol0 : COLOR0,\n"
|
||||
" in float2 uv0 : TEXCOORD0)\n"
|
||||
"{\n"
|
||||
" float2 uv1 = float2((uv0.x + 1.0f)/ blkDims.z, uv0.y / blkDims.w);\n"
|
||||
" float3 c0 = tex2D(samp0, uv0.xy / blkDims.zw).rgb;\n"
|
||||
" float3 c1 = tex2D(samp0, uv1).rgb;\n"
|
||||
" float3 y_const = float3(0.257f,0.504f,0.098f);\n"
|
||||
" float3 u_const = float3(-0.148f,-0.291f,0.439f);\n"
|
||||
" float3 v_const = float3(0.439f,-0.368f,-0.071f);\n"
|
||||
" float4 const3 = float4(0.0625f,0.5f,0.0625f,0.5f);\n"
|
||||
" float3 c01 = (c0 + c1) * 0.5f;\n"
|
||||
" ocol0 = float4(dot(c1,y_const),dot(c01,u_const),dot(c0,y_const),dot(c01, v_const)) + const3;\n"
|
||||
"}\n",C_COLORMATRIX,C_COLORMATRIX+1);
|
||||
|
||||
s_rgbToYuyvProgram = D3D::CompileAndCreatePixelShader(FProgram, (int)strlen(FProgram));
|
||||
if (!s_rgbToYuyvProgram) {
|
||||
ERROR_LOG(VIDEO, "Failed to create RGB to YUYV fragment program");
|
||||
}
|
||||
delete [] FProgram;
|
||||
}
|
||||
|
||||
void CreateYuyvToRgbProgram()
|
||||
{
|
||||
char* FProgram = new char[2048];
|
||||
sprintf(FProgram,"uniform float4 blkDims : register(c%d);\n"
|
||||
"uniform float4 textureDims : register(c%d);\n"
|
||||
"uniform sampler samp0 : register(s0);\n"
|
||||
"void main(\n"
|
||||
" out float4 ocol0 : COLOR0,\n"
|
||||
" in float2 uv0 : TEXCOORD0)\n"
|
||||
"{\n"
|
||||
" float4 c0 = tex2D(samp0, uv0 / blkDims.zw).rgba;\n"
|
||||
" float f = step(0.5, frac(uv0.x));\n"
|
||||
" float y = lerp(c0.b, c0.r, f);\n"
|
||||
" float yComp = 1.164f * (y - 0.0625f);\n"
|
||||
" float uComp = c0.g - 0.5f;\n"
|
||||
" float vComp = c0.a - 0.5f;\n"
|
||||
|
||||
" ocol0 = float4(yComp + (1.596f * vComp),\n"
|
||||
" yComp - (0.813f * vComp) - (0.391f * uComp),\n"
|
||||
" yComp + (2.018f * uComp),\n"
|
||||
" 1.0f);\n"
|
||||
"}\n",C_COLORMATRIX,C_COLORMATRIX+1);
|
||||
s_yuyvToRgbProgram = D3D::CompileAndCreatePixelShader(FProgram, (int)strlen(FProgram));
|
||||
if (!s_yuyvToRgbProgram) {
|
||||
ERROR_LOG(VIDEO, "Failed to create YUYV to RGB fragment program");
|
||||
}
|
||||
delete [] FProgram;
|
||||
}
|
||||
|
||||
LPDIRECT3DPIXELSHADER9 GetOrCreateEncodingShader(u32 format)
|
||||
{
|
||||
if (format > NUM_ENCODING_PROGRAMS)
|
||||
{
|
||||
PanicAlert("Unknown texture copy format: 0x%x\n", format);
|
||||
return s_encodingPrograms[0];
|
||||
}
|
||||
|
||||
if (!s_encodingPrograms[format])
|
||||
{
|
||||
const char* shader = TextureConversionShader::GenerateEncodingShader(format,true);
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && shader) {
|
||||
static int counter = 0;
|
||||
char szTemp[MAX_PATH];
|
||||
sprintf(szTemp, "%senc_%04i.txt", File::GetUserPath(D_DUMP_IDX), counter++);
|
||||
|
||||
SaveData(szTemp, shader);
|
||||
}
|
||||
#endif
|
||||
s_encodingPrograms[format] = D3D::CompileAndCreatePixelShader(shader, (int)strlen(shader));
|
||||
if (!s_encodingPrograms[format]) {
|
||||
ERROR_LOG(VIDEO, "Failed to create encoding fragment program");
|
||||
}
|
||||
}
|
||||
return s_encodingPrograms[format];
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
for (unsigned int i = 0; i < NUM_ENCODING_PROGRAMS; i++)
|
||||
{
|
||||
s_encodingPrograms[i] = NULL;
|
||||
}
|
||||
for (unsigned int i = 0; i < NUM_TRANSFORM_BUFFERS; i++)
|
||||
{
|
||||
TrnBuffers[i].FBTexture = NULL;
|
||||
TrnBuffers[i].RenderSurface = NULL;
|
||||
TrnBuffers[i].ReadSurface = NULL;
|
||||
TrnBuffers[i].Width = 0;
|
||||
TrnBuffers[i].Height = 0;
|
||||
}
|
||||
CreateRgbToYuyvProgram();
|
||||
CreateYuyvToRgbProgram();
|
||||
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
if(s_rgbToYuyvProgram)
|
||||
s_rgbToYuyvProgram->Release();
|
||||
s_rgbToYuyvProgram = NULL;
|
||||
if(s_yuyvToRgbProgram)
|
||||
s_yuyvToRgbProgram->Release();
|
||||
s_yuyvToRgbProgram=NULL;
|
||||
|
||||
for (unsigned int i = 0; i < NUM_ENCODING_PROGRAMS; i++)
|
||||
{
|
||||
if(s_encodingPrograms[i])
|
||||
s_encodingPrograms[i]->Release();
|
||||
s_encodingPrograms[i] = NULL;
|
||||
}
|
||||
for (unsigned int i = 0; i < NUM_TRANSFORM_BUFFERS; i++)
|
||||
{
|
||||
if(TrnBuffers[i].RenderSurface != NULL)
|
||||
TrnBuffers[i].RenderSurface->Release();
|
||||
TrnBuffers[i].RenderSurface = NULL;
|
||||
|
||||
if(TrnBuffers[i].ReadSurface != NULL)
|
||||
TrnBuffers[i].ReadSurface->Release();
|
||||
TrnBuffers[i].ReadSurface = NULL;
|
||||
|
||||
if(TrnBuffers[i].FBTexture != NULL)
|
||||
TrnBuffers[i].FBTexture->Release();
|
||||
TrnBuffers[i].FBTexture = NULL;
|
||||
|
||||
TrnBuffers[i].Width = 0;
|
||||
TrnBuffers[i].Height = 0;
|
||||
}
|
||||
WorkingBuffers = 0;
|
||||
}
|
||||
|
||||
void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 srcTexture, const TargetRectangle& sourceRc,
|
||||
u8* destAddr, int dstWidth, int dstHeight, int readStride, bool toTexture, bool linearFilter)
|
||||
{
|
||||
HRESULT hr;
|
||||
Renderer::ResetAPIState();
|
||||
u32 index =0;
|
||||
while(index < WorkingBuffers && (TrnBuffers[index].Width != dstWidth || TrnBuffers[index].Height != dstHeight))
|
||||
index++;
|
||||
|
||||
LPDIRECT3DSURFACE9 s_texConvReadSurface = NULL;
|
||||
LPDIRECT3DSURFACE9 Rendersurf = NULL;
|
||||
|
||||
if (index >= WorkingBuffers)
|
||||
{
|
||||
if (WorkingBuffers < NUM_TRANSFORM_BUFFERS)
|
||||
WorkingBuffers++;
|
||||
if (index >= WorkingBuffers)
|
||||
index--;
|
||||
if (TrnBuffers[index].RenderSurface != NULL)
|
||||
{
|
||||
TrnBuffers[index].RenderSurface->Release();
|
||||
TrnBuffers[index].RenderSurface = NULL;
|
||||
}
|
||||
if (TrnBuffers[index].ReadSurface != NULL)
|
||||
{
|
||||
TrnBuffers[index].ReadSurface->Release();
|
||||
TrnBuffers[index].ReadSurface = NULL;
|
||||
}
|
||||
if (TrnBuffers[index].FBTexture != NULL)
|
||||
{
|
||||
TrnBuffers[index].FBTexture->Release();
|
||||
TrnBuffers[index].FBTexture = NULL;
|
||||
}
|
||||
TrnBuffers[index].Width = dstWidth;
|
||||
TrnBuffers[index].Height = dstHeight;
|
||||
D3D::dev->CreateTexture(dstWidth, dstHeight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
|
||||
D3DPOOL_DEFAULT, &TrnBuffers[index].FBTexture, NULL);
|
||||
TrnBuffers[index].FBTexture->GetSurfaceLevel(0,&TrnBuffers[index].RenderSurface);
|
||||
D3D::dev->CreateOffscreenPlainSurface(dstWidth, dstHeight, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &TrnBuffers[index].ReadSurface, NULL );
|
||||
}
|
||||
|
||||
s_texConvReadSurface = TrnBuffers[index].ReadSurface;
|
||||
Rendersurf = TrnBuffers[index].RenderSurface;
|
||||
|
||||
hr = D3D::dev->SetDepthStencilSurface(NULL);
|
||||
hr = D3D::dev->SetRenderTarget(0, Rendersurf);
|
||||
|
||||
if (linearFilter)
|
||||
{
|
||||
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
|
||||
}
|
||||
|
||||
D3DVIEWPORT9 vp;
|
||||
vp.X = 0;
|
||||
vp.Y = 0;
|
||||
vp.Width = dstWidth;
|
||||
vp.Height = dstHeight;
|
||||
vp.MinZ = 0.0f;
|
||||
vp.MaxZ = 1.0f;
|
||||
hr = D3D::dev->SetViewport(&vp);
|
||||
RECT SrcRect;
|
||||
SrcRect.top = sourceRc.top;
|
||||
SrcRect.left = sourceRc.left;
|
||||
SrcRect.right = sourceRc.right;
|
||||
SrcRect.bottom = sourceRc.bottom;
|
||||
RECT DstRect;
|
||||
DstRect.top = 0;
|
||||
DstRect.left = 0;
|
||||
DstRect.right = dstWidth;
|
||||
DstRect.bottom = dstHeight;
|
||||
|
||||
|
||||
// Draw...
|
||||
D3D::drawShadedTexQuad(srcTexture,&SrcRect,1,1,dstWidth,dstHeight,shader,VertexShaderCache::GetSimpleVertexShader(0));
|
||||
hr = D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
||||
hr = D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
Renderer::RestoreAPIState();
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
|
||||
// .. and then readback the results.
|
||||
// TODO: make this less slow.
|
||||
|
||||
D3DLOCKED_RECT drect;
|
||||
|
||||
|
||||
hr = D3D::dev->GetRenderTargetData(Rendersurf,s_texConvReadSurface);
|
||||
if((hr = s_texConvReadSurface->LockRect(&drect, &DstRect, D3DLOCK_READONLY)) != D3D_OK)
|
||||
{
|
||||
PanicAlert("ERROR: %s", hr == D3DERR_WASSTILLDRAWING ? "Still drawing" :
|
||||
hr == D3DERR_INVALIDCALL ? "Invalid call" : "w00t");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
int writeStride = bpmem.copyMipMapStrideChannels * 32;
|
||||
|
||||
if (writeStride != readStride && toTexture)
|
||||
{
|
||||
// writing to a texture of a different size
|
||||
|
||||
int readHeight = readStride / dstWidth;
|
||||
|
||||
int readStart = 0;
|
||||
int readLoops = dstHeight / (readHeight/4); // 4 bytes per pixel
|
||||
u8 *Source = (u8*)drect.pBits;
|
||||
for (int i = 0; i < readLoops; i++)
|
||||
{
|
||||
int readDist = dstWidth*readHeight;
|
||||
memcpy(destAddr,Source,readDist);
|
||||
Source += readDist;
|
||||
destAddr += writeStride;
|
||||
}
|
||||
}
|
||||
else
|
||||
memcpy(destAddr,drect.pBits,dstWidth*dstHeight*4);// 4 bytes per pixel
|
||||
|
||||
hr = s_texConvReadSurface->UnlockRect();
|
||||
}
|
||||
}
|
||||
|
||||
void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source)
|
||||
{
|
||||
u32 format = copyfmt;
|
||||
|
||||
if (bFromZBuffer)
|
||||
{
|
||||
format |= _GX_TF_ZTF;
|
||||
if (copyfmt == 11)
|
||||
format = GX_TF_Z16;
|
||||
else if (format < GX_TF_Z8 || format > GX_TF_Z24X8)
|
||||
format |= _GX_TF_CTF;
|
||||
}
|
||||
else
|
||||
if (copyfmt > GX_TF_RGBA8 || (copyfmt < GX_TF_RGB565 && !bIsIntensityFmt))
|
||||
format |= _GX_TF_CTF;
|
||||
|
||||
LPDIRECT3DPIXELSHADER9 texconv_shader = GetOrCreateEncodingShader(format);
|
||||
if (!texconv_shader)
|
||||
return;
|
||||
|
||||
u8 *dest_ptr = Memory_GetPtr(address);
|
||||
|
||||
LPDIRECT3DTEXTURE9 source_texture = bFromZBuffer ? FBManager.GetEFBDepthTexture(source) : FBManager.GetEFBColorTexture(source);
|
||||
int width = (source.right - source.left) >> bScaleByHalf;
|
||||
int height = (source.bottom - source.top) >> bScaleByHalf;
|
||||
|
||||
int size_in_bytes = TexDecoder_GetTextureSizeInBytes(width, height, format);
|
||||
|
||||
// Invalidate any existing texture covering this memory range.
|
||||
// TODO - don't delete the texture if it already exists, just replace the contents.
|
||||
TextureCache::InvalidateRange(address, size_in_bytes);
|
||||
|
||||
u16 blkW = TexDecoder_GetBlockWidthInTexels(format) - 1;
|
||||
u16 blkH = TexDecoder_GetBlockHeightInTexels(format) - 1;
|
||||
u16 samples = TextureConversionShader::GetEncodedSampleCount(format);
|
||||
|
||||
// only copy on cache line boundaries
|
||||
// extra pixels are copied but not displayed in the resulting texture
|
||||
s32 expandedWidth = (width + blkW) & (~blkW);
|
||||
s32 expandedHeight = (height + blkH) & (~blkH);
|
||||
|
||||
float MValueX = Renderer::GetTargetScaleX();
|
||||
float MValueY = Renderer::GetTargetScaleY();
|
||||
|
||||
float Xstride = (float)((Renderer::GetFullTargetWidth() - Renderer::GetTargetWidth()) / 2);
|
||||
float Ystride = (float)((Renderer::GetFullTargetHeight() - Renderer::GetTargetHeight()) / 2);
|
||||
|
||||
float sampleStride = bScaleByHalf?2.0f:1.0f;
|
||||
|
||||
TextureConversionShader::SetShaderParameters(
|
||||
(float)expandedWidth,
|
||||
expandedHeight * MValueY,
|
||||
source.left * MValueX + Xstride ,
|
||||
source.top * MValueY + Ystride,
|
||||
sampleStride * MValueX,
|
||||
sampleStride * MValueY,
|
||||
(float)Renderer::GetFullTargetWidth(),
|
||||
(float)Renderer::GetFullTargetHeight());
|
||||
|
||||
TargetRectangle scaledSource;
|
||||
scaledSource.top = 0;
|
||||
scaledSource.bottom = expandedHeight;
|
||||
scaledSource.left = 0;
|
||||
scaledSource.right = expandedWidth / samples;
|
||||
int cacheBytes = 32;
|
||||
if ((format & 0x0f) == 6)
|
||||
cacheBytes = 64;
|
||||
|
||||
int readStride = (expandedWidth * cacheBytes) / TexDecoder_GetBlockWidthInTexels(format);
|
||||
EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight,readStride, true, bScaleByHalf > 0);
|
||||
}
|
||||
|
||||
void EncodeToRamYUYV(LPDIRECT3DTEXTURE9 srcTexture, const TargetRectangle& sourceRc,u8* destAddr, int dstWidth, int dstHeight)
|
||||
{
|
||||
TextureConversionShader::SetShaderParameters(
|
||||
(float)dstWidth,
|
||||
(float)dstHeight,
|
||||
0.0f ,
|
||||
0.0f,
|
||||
1.0f,
|
||||
1.0f,
|
||||
(float)Renderer::GetFullTargetWidth(),
|
||||
(float)Renderer::GetFullTargetHeight());
|
||||
EncodeToRamUsingShader(s_rgbToYuyvProgram, srcTexture, sourceRc, destAddr, dstWidth / 2, dstHeight, 0, false, false);
|
||||
}
|
||||
|
||||
|
||||
// Should be scale free.
|
||||
void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, LPDIRECT3DTEXTURE9 destTexture)
|
||||
{
|
||||
u8* srcAddr = Memory_GetPtr(xfbAddr);
|
||||
if (!srcAddr)
|
||||
{
|
||||
WARN_LOG(VIDEO, "Tried to decode from invalid memory address");
|
||||
return;
|
||||
}
|
||||
|
||||
int srcFmtWidth = srcWidth / 2;
|
||||
|
||||
Renderer::ResetAPIState(); // reset any game specific settings
|
||||
LPDIRECT3DTEXTURE9 s_srcTexture = D3D::CreateTexture2D(srcAddr, srcFmtWidth, srcHeight, srcFmtWidth, D3DFMT_A8R8G8B8, false);
|
||||
LPDIRECT3DSURFACE9 Rendersurf = NULL;
|
||||
destTexture->GetSurfaceLevel(0,&Rendersurf);
|
||||
D3D::dev->SetDepthStencilSurface(NULL);
|
||||
D3D::dev->SetRenderTarget(0, Rendersurf);
|
||||
|
||||
D3DVIEWPORT9 vp;
|
||||
|
||||
// Stretch picture with increased internal resolution
|
||||
vp.X = 0;
|
||||
vp.Y = 0;
|
||||
vp.Width = srcWidth;
|
||||
vp.Height = srcHeight;
|
||||
vp.MinZ = 0.0f;
|
||||
vp.MaxZ = 1.0f;
|
||||
D3D::dev->SetViewport(&vp);
|
||||
RECT destrect;
|
||||
destrect.bottom = srcHeight;
|
||||
destrect.left = 0;
|
||||
destrect.right = srcWidth;
|
||||
destrect.top = 0;
|
||||
|
||||
RECT sourcerect;
|
||||
sourcerect.bottom = srcHeight;
|
||||
sourcerect.left = 0;
|
||||
sourcerect.right = srcFmtWidth;
|
||||
sourcerect.top = 0;
|
||||
|
||||
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
|
||||
D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
|
||||
|
||||
TextureConversionShader::SetShaderParameters(
|
||||
(float)srcFmtWidth,
|
||||
(float)srcHeight,
|
||||
0.0f ,
|
||||
0.0f,
|
||||
1.0f,
|
||||
1.0f,
|
||||
(float)srcFmtWidth,
|
||||
(float)srcHeight);
|
||||
D3D::drawShadedTexQuad(
|
||||
s_srcTexture,
|
||||
&sourcerect,
|
||||
1 ,
|
||||
1,
|
||||
srcWidth,
|
||||
srcHeight,
|
||||
s_yuyvToRgbProgram,
|
||||
VertexShaderCache::GetSimpleVertexShader(0));
|
||||
|
||||
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER);
|
||||
D3D::SetTexture(0,NULL);
|
||||
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
Renderer::RestoreAPIState();
|
||||
Rendersurf->Release();
|
||||
s_srcTexture->Release();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
// 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/
|
||||
|
||||
// Fast image conversion using OpenGL shaders.
|
||||
// This kind of stuff would be a LOT nicer with OpenCL.
|
||||
|
||||
#include "TextureConverter.h"
|
||||
#include "TextureConversionShader.h"
|
||||
#include "PixelShaderCache.h"
|
||||
#include "VertexShaderManager.h"
|
||||
#include "VertexShaderCache.h"
|
||||
#include "FramebufferManager.h"
|
||||
#include "Globals.h"
|
||||
#include "VideoConfig.h"
|
||||
#include "ImageWrite.h"
|
||||
#include "Render.h"
|
||||
#include "TextureCache.h"
|
||||
#include "Math.h"
|
||||
#include "FileUtil.h"
|
||||
|
||||
namespace TextureConverter
|
||||
{
|
||||
struct TransformBuffer
|
||||
{
|
||||
LPDIRECT3DTEXTURE9 FBTexture;
|
||||
LPDIRECT3DSURFACE9 RenderSurface;
|
||||
LPDIRECT3DSURFACE9 ReadSurface;
|
||||
int Width;
|
||||
int Height;
|
||||
};
|
||||
const u32 NUM_TRANSFORM_BUFFERS = 16;
|
||||
static TransformBuffer TrnBuffers[NUM_TRANSFORM_BUFFERS];
|
||||
static u32 WorkingBuffers = 0;
|
||||
|
||||
static LPDIRECT3DPIXELSHADER9 s_rgbToYuyvProgram = NULL;
|
||||
static LPDIRECT3DPIXELSHADER9 s_yuyvToRgbProgram = NULL;
|
||||
|
||||
// Not all slots are taken - but who cares.
|
||||
const u32 NUM_ENCODING_PROGRAMS = 64;
|
||||
static LPDIRECT3DPIXELSHADER9 s_encodingPrograms[NUM_ENCODING_PROGRAMS];
|
||||
|
||||
void CreateRgbToYuyvProgram()
|
||||
{
|
||||
// Output is BGRA because that is slightly faster than RGBA.
|
||||
char* FProgram = new char[2048];
|
||||
sprintf(FProgram,"uniform float4 blkDims : register(c%d);\n"
|
||||
"uniform float4 textureDims : register(c%d);\n"
|
||||
"uniform sampler samp0 : register(s0);\n"
|
||||
"void main(\n"
|
||||
" out float4 ocol0 : COLOR0,\n"
|
||||
" in float2 uv0 : TEXCOORD0)\n"
|
||||
"{\n"
|
||||
" float2 uv1 = float2((uv0.x + 1.0f)/ blkDims.z, uv0.y / blkDims.w);\n"
|
||||
" float3 c0 = tex2D(samp0, uv0.xy / blkDims.zw).rgb;\n"
|
||||
" float3 c1 = tex2D(samp0, uv1).rgb;\n"
|
||||
" float3 y_const = float3(0.257f,0.504f,0.098f);\n"
|
||||
" float3 u_const = float3(-0.148f,-0.291f,0.439f);\n"
|
||||
" float3 v_const = float3(0.439f,-0.368f,-0.071f);\n"
|
||||
" float4 const3 = float4(0.0625f,0.5f,0.0625f,0.5f);\n"
|
||||
" float3 c01 = (c0 + c1) * 0.5f;\n"
|
||||
" ocol0 = float4(dot(c1,y_const),dot(c01,u_const),dot(c0,y_const),dot(c01, v_const)) + const3;\n"
|
||||
"}\n",C_COLORMATRIX,C_COLORMATRIX+1);
|
||||
|
||||
s_rgbToYuyvProgram = D3D::CompileAndCreatePixelShader(FProgram, (int)strlen(FProgram));
|
||||
if (!s_rgbToYuyvProgram) {
|
||||
ERROR_LOG(VIDEO, "Failed to create RGB to YUYV fragment program");
|
||||
}
|
||||
delete [] FProgram;
|
||||
}
|
||||
|
||||
void CreateYuyvToRgbProgram()
|
||||
{
|
||||
char* FProgram = new char[2048];
|
||||
sprintf(FProgram,"uniform float4 blkDims : register(c%d);\n"
|
||||
"uniform float4 textureDims : register(c%d);\n"
|
||||
"uniform sampler samp0 : register(s0);\n"
|
||||
"void main(\n"
|
||||
" out float4 ocol0 : COLOR0,\n"
|
||||
" in float2 uv0 : TEXCOORD0)\n"
|
||||
"{\n"
|
||||
" float4 c0 = tex2D(samp0, uv0 / blkDims.zw).rgba;\n"
|
||||
" float f = step(0.5, frac(uv0.x));\n"
|
||||
" float y = lerp(c0.b, c0.r, f);\n"
|
||||
" float yComp = 1.164f * (y - 0.0625f);\n"
|
||||
" float uComp = c0.g - 0.5f;\n"
|
||||
" float vComp = c0.a - 0.5f;\n"
|
||||
|
||||
" ocol0 = float4(yComp + (1.596f * vComp),\n"
|
||||
" yComp - (0.813f * vComp) - (0.391f * uComp),\n"
|
||||
" yComp + (2.018f * uComp),\n"
|
||||
" 1.0f);\n"
|
||||
"}\n",C_COLORMATRIX,C_COLORMATRIX+1);
|
||||
s_yuyvToRgbProgram = D3D::CompileAndCreatePixelShader(FProgram, (int)strlen(FProgram));
|
||||
if (!s_yuyvToRgbProgram) {
|
||||
ERROR_LOG(VIDEO, "Failed to create YUYV to RGB fragment program");
|
||||
}
|
||||
delete [] FProgram;
|
||||
}
|
||||
|
||||
LPDIRECT3DPIXELSHADER9 GetOrCreateEncodingShader(u32 format)
|
||||
{
|
||||
if (format > NUM_ENCODING_PROGRAMS)
|
||||
{
|
||||
PanicAlert("Unknown texture copy format: 0x%x\n", format);
|
||||
return s_encodingPrograms[0];
|
||||
}
|
||||
|
||||
if (!s_encodingPrograms[format])
|
||||
{
|
||||
const char* shader = TextureConversionShader::GenerateEncodingShader(format,true);
|
||||
|
||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
||||
if (g_ActiveConfig.iLog & CONF_SAVESHADERS && shader) {
|
||||
static int counter = 0;
|
||||
char szTemp[MAX_PATH];
|
||||
sprintf(szTemp, "%senc_%04i.txt", File::GetUserPath(D_DUMP_IDX), counter++);
|
||||
|
||||
SaveData(szTemp, shader);
|
||||
}
|
||||
#endif
|
||||
s_encodingPrograms[format] = D3D::CompileAndCreatePixelShader(shader, (int)strlen(shader));
|
||||
if (!s_encodingPrograms[format]) {
|
||||
ERROR_LOG(VIDEO, "Failed to create encoding fragment program");
|
||||
}
|
||||
}
|
||||
return s_encodingPrograms[format];
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
for (unsigned int i = 0; i < NUM_ENCODING_PROGRAMS; i++)
|
||||
{
|
||||
s_encodingPrograms[i] = NULL;
|
||||
}
|
||||
for (unsigned int i = 0; i < NUM_TRANSFORM_BUFFERS; i++)
|
||||
{
|
||||
TrnBuffers[i].FBTexture = NULL;
|
||||
TrnBuffers[i].RenderSurface = NULL;
|
||||
TrnBuffers[i].ReadSurface = NULL;
|
||||
TrnBuffers[i].Width = 0;
|
||||
TrnBuffers[i].Height = 0;
|
||||
}
|
||||
CreateRgbToYuyvProgram();
|
||||
CreateYuyvToRgbProgram();
|
||||
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
if(s_rgbToYuyvProgram)
|
||||
s_rgbToYuyvProgram->Release();
|
||||
s_rgbToYuyvProgram = NULL;
|
||||
if(s_yuyvToRgbProgram)
|
||||
s_yuyvToRgbProgram->Release();
|
||||
s_yuyvToRgbProgram=NULL;
|
||||
|
||||
for (unsigned int i = 0; i < NUM_ENCODING_PROGRAMS; i++)
|
||||
{
|
||||
if(s_encodingPrograms[i])
|
||||
s_encodingPrograms[i]->Release();
|
||||
s_encodingPrograms[i] = NULL;
|
||||
}
|
||||
for (unsigned int i = 0; i < NUM_TRANSFORM_BUFFERS; i++)
|
||||
{
|
||||
if(TrnBuffers[i].RenderSurface != NULL)
|
||||
TrnBuffers[i].RenderSurface->Release();
|
||||
TrnBuffers[i].RenderSurface = NULL;
|
||||
|
||||
if(TrnBuffers[i].ReadSurface != NULL)
|
||||
TrnBuffers[i].ReadSurface->Release();
|
||||
TrnBuffers[i].ReadSurface = NULL;
|
||||
|
||||
if(TrnBuffers[i].FBTexture != NULL)
|
||||
TrnBuffers[i].FBTexture->Release();
|
||||
TrnBuffers[i].FBTexture = NULL;
|
||||
|
||||
TrnBuffers[i].Width = 0;
|
||||
TrnBuffers[i].Height = 0;
|
||||
}
|
||||
WorkingBuffers = 0;
|
||||
}
|
||||
|
||||
void EncodeToRamUsingShader(LPDIRECT3DPIXELSHADER9 shader, LPDIRECT3DTEXTURE9 srcTexture, const TargetRectangle& sourceRc,
|
||||
u8* destAddr, int dstWidth, int dstHeight, int readStride, bool toTexture, bool linearFilter)
|
||||
{
|
||||
HRESULT hr;
|
||||
Renderer::ResetAPIState();
|
||||
u32 index =0;
|
||||
while(index < WorkingBuffers && (TrnBuffers[index].Width != dstWidth || TrnBuffers[index].Height != dstHeight))
|
||||
index++;
|
||||
|
||||
LPDIRECT3DSURFACE9 s_texConvReadSurface = NULL;
|
||||
LPDIRECT3DSURFACE9 Rendersurf = NULL;
|
||||
|
||||
if (index >= WorkingBuffers)
|
||||
{
|
||||
if (WorkingBuffers < NUM_TRANSFORM_BUFFERS)
|
||||
WorkingBuffers++;
|
||||
if (index >= WorkingBuffers)
|
||||
index--;
|
||||
if (TrnBuffers[index].RenderSurface != NULL)
|
||||
{
|
||||
TrnBuffers[index].RenderSurface->Release();
|
||||
TrnBuffers[index].RenderSurface = NULL;
|
||||
}
|
||||
if (TrnBuffers[index].ReadSurface != NULL)
|
||||
{
|
||||
TrnBuffers[index].ReadSurface->Release();
|
||||
TrnBuffers[index].ReadSurface = NULL;
|
||||
}
|
||||
if (TrnBuffers[index].FBTexture != NULL)
|
||||
{
|
||||
TrnBuffers[index].FBTexture->Release();
|
||||
TrnBuffers[index].FBTexture = NULL;
|
||||
}
|
||||
TrnBuffers[index].Width = dstWidth;
|
||||
TrnBuffers[index].Height = dstHeight;
|
||||
D3D::dev->CreateTexture(dstWidth, dstHeight, 1, D3DUSAGE_RENDERTARGET, D3DFMT_A8R8G8B8,
|
||||
D3DPOOL_DEFAULT, &TrnBuffers[index].FBTexture, NULL);
|
||||
TrnBuffers[index].FBTexture->GetSurfaceLevel(0,&TrnBuffers[index].RenderSurface);
|
||||
D3D::dev->CreateOffscreenPlainSurface(dstWidth, dstHeight, D3DFMT_A8R8G8B8, D3DPOOL_SYSTEMMEM, &TrnBuffers[index].ReadSurface, NULL );
|
||||
}
|
||||
|
||||
s_texConvReadSurface = TrnBuffers[index].ReadSurface;
|
||||
Rendersurf = TrnBuffers[index].RenderSurface;
|
||||
|
||||
hr = D3D::dev->SetDepthStencilSurface(NULL);
|
||||
hr = D3D::dev->SetRenderTarget(0, Rendersurf);
|
||||
|
||||
if (linearFilter)
|
||||
{
|
||||
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
|
||||
}
|
||||
|
||||
D3DVIEWPORT9 vp;
|
||||
vp.X = 0;
|
||||
vp.Y = 0;
|
||||
vp.Width = dstWidth;
|
||||
vp.Height = dstHeight;
|
||||
vp.MinZ = 0.0f;
|
||||
vp.MaxZ = 1.0f;
|
||||
hr = D3D::dev->SetViewport(&vp);
|
||||
RECT SrcRect;
|
||||
SrcRect.top = sourceRc.top;
|
||||
SrcRect.left = sourceRc.left;
|
||||
SrcRect.right = sourceRc.right;
|
||||
SrcRect.bottom = sourceRc.bottom;
|
||||
RECT DstRect;
|
||||
DstRect.top = 0;
|
||||
DstRect.left = 0;
|
||||
DstRect.right = dstWidth;
|
||||
DstRect.bottom = dstHeight;
|
||||
|
||||
|
||||
// Draw...
|
||||
D3D::drawShadedTexQuad(srcTexture,&SrcRect,1,1,dstWidth,dstHeight,shader,VertexShaderCache::GetSimpleVertexShader(0));
|
||||
hr = D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
||||
hr = D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
Renderer::RestoreAPIState();
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
|
||||
// .. and then readback the results.
|
||||
// TODO: make this less slow.
|
||||
|
||||
D3DLOCKED_RECT drect;
|
||||
|
||||
|
||||
hr = D3D::dev->GetRenderTargetData(Rendersurf,s_texConvReadSurface);
|
||||
if((hr = s_texConvReadSurface->LockRect(&drect, &DstRect, D3DLOCK_READONLY)) != D3D_OK)
|
||||
{
|
||||
PanicAlert("ERROR: %s", hr == D3DERR_WASSTILLDRAWING ? "Still drawing" :
|
||||
hr == D3DERR_INVALIDCALL ? "Invalid call" : "w00t");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
int writeStride = bpmem.copyMipMapStrideChannels * 32;
|
||||
|
||||
if (writeStride != readStride && toTexture)
|
||||
{
|
||||
// writing to a texture of a different size
|
||||
|
||||
int readHeight = readStride / dstWidth;
|
||||
|
||||
int readStart = 0;
|
||||
int readLoops = dstHeight / (readHeight/4); // 4 bytes per pixel
|
||||
u8 *Source = (u8*)drect.pBits;
|
||||
for (int i = 0; i < readLoops; i++)
|
||||
{
|
||||
int readDist = dstWidth*readHeight;
|
||||
memcpy(destAddr,Source,readDist);
|
||||
Source += readDist;
|
||||
destAddr += writeStride;
|
||||
}
|
||||
}
|
||||
else
|
||||
memcpy(destAddr,drect.pBits,dstWidth*dstHeight*4);// 4 bytes per pixel
|
||||
|
||||
hr = s_texConvReadSurface->UnlockRect();
|
||||
}
|
||||
}
|
||||
|
||||
void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyfmt, int bScaleByHalf, const EFBRectangle& source)
|
||||
{
|
||||
u32 format = copyfmt;
|
||||
|
||||
if (bFromZBuffer)
|
||||
{
|
||||
format |= _GX_TF_ZTF;
|
||||
if (copyfmt == 11)
|
||||
format = GX_TF_Z16;
|
||||
else if (format < GX_TF_Z8 || format > GX_TF_Z24X8)
|
||||
format |= _GX_TF_CTF;
|
||||
}
|
||||
else
|
||||
if (copyfmt > GX_TF_RGBA8 || (copyfmt < GX_TF_RGB565 && !bIsIntensityFmt))
|
||||
format |= _GX_TF_CTF;
|
||||
|
||||
LPDIRECT3DPIXELSHADER9 texconv_shader = GetOrCreateEncodingShader(format);
|
||||
if (!texconv_shader)
|
||||
return;
|
||||
|
||||
u8 *dest_ptr = Memory_GetPtr(address);
|
||||
|
||||
LPDIRECT3DTEXTURE9 source_texture = bFromZBuffer ? FBManager.GetEFBDepthTexture(source) : FBManager.GetEFBColorTexture(source);
|
||||
int width = (source.right - source.left) >> bScaleByHalf;
|
||||
int height = (source.bottom - source.top) >> bScaleByHalf;
|
||||
|
||||
int size_in_bytes = TexDecoder_GetTextureSizeInBytes(width, height, format);
|
||||
|
||||
// Invalidate any existing texture covering this memory range.
|
||||
// TODO - don't delete the texture if it already exists, just replace the contents.
|
||||
TextureCache::InvalidateRange(address, size_in_bytes);
|
||||
|
||||
u16 blkW = TexDecoder_GetBlockWidthInTexels(format) - 1;
|
||||
u16 blkH = TexDecoder_GetBlockHeightInTexels(format) - 1;
|
||||
u16 samples = TextureConversionShader::GetEncodedSampleCount(format);
|
||||
|
||||
// only copy on cache line boundaries
|
||||
// extra pixels are copied but not displayed in the resulting texture
|
||||
s32 expandedWidth = (width + blkW) & (~blkW);
|
||||
s32 expandedHeight = (height + blkH) & (~blkH);
|
||||
|
||||
float MValueX = Renderer::GetTargetScaleX();
|
||||
float MValueY = Renderer::GetTargetScaleY();
|
||||
|
||||
float Xstride = (float)((Renderer::GetFullTargetWidth() - Renderer::GetTargetWidth()) / 2);
|
||||
float Ystride = (float)((Renderer::GetFullTargetHeight() - Renderer::GetTargetHeight()) / 2);
|
||||
|
||||
float sampleStride = bScaleByHalf?2.0f:1.0f;
|
||||
|
||||
TextureConversionShader::SetShaderParameters(
|
||||
(float)expandedWidth,
|
||||
expandedHeight * MValueY,
|
||||
source.left * MValueX + Xstride ,
|
||||
source.top * MValueY + Ystride,
|
||||
sampleStride * MValueX,
|
||||
sampleStride * MValueY,
|
||||
(float)Renderer::GetFullTargetWidth(),
|
||||
(float)Renderer::GetFullTargetHeight());
|
||||
|
||||
TargetRectangle scaledSource;
|
||||
scaledSource.top = 0;
|
||||
scaledSource.bottom = expandedHeight;
|
||||
scaledSource.left = 0;
|
||||
scaledSource.right = expandedWidth / samples;
|
||||
int cacheBytes = 32;
|
||||
if ((format & 0x0f) == 6)
|
||||
cacheBytes = 64;
|
||||
|
||||
int readStride = (expandedWidth * cacheBytes) / TexDecoder_GetBlockWidthInTexels(format);
|
||||
EncodeToRamUsingShader(texconv_shader, source_texture, scaledSource, dest_ptr, expandedWidth / samples, expandedHeight,readStride, true, bScaleByHalf > 0);
|
||||
}
|
||||
|
||||
void EncodeToRamYUYV(LPDIRECT3DTEXTURE9 srcTexture, const TargetRectangle& sourceRc,u8* destAddr, int dstWidth, int dstHeight)
|
||||
{
|
||||
TextureConversionShader::SetShaderParameters(
|
||||
(float)dstWidth,
|
||||
(float)dstHeight,
|
||||
0.0f ,
|
||||
0.0f,
|
||||
1.0f,
|
||||
1.0f,
|
||||
(float)Renderer::GetFullTargetWidth(),
|
||||
(float)Renderer::GetFullTargetHeight());
|
||||
EncodeToRamUsingShader(s_rgbToYuyvProgram, srcTexture, sourceRc, destAddr, dstWidth / 2, dstHeight, 0, false, false);
|
||||
}
|
||||
|
||||
|
||||
// Should be scale free.
|
||||
void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, LPDIRECT3DTEXTURE9 destTexture)
|
||||
{
|
||||
u8* srcAddr = Memory_GetPtr(xfbAddr);
|
||||
if (!srcAddr)
|
||||
{
|
||||
WARN_LOG(VIDEO, "Tried to decode from invalid memory address");
|
||||
return;
|
||||
}
|
||||
|
||||
int srcFmtWidth = srcWidth / 2;
|
||||
|
||||
Renderer::ResetAPIState(); // reset any game specific settings
|
||||
LPDIRECT3DTEXTURE9 s_srcTexture = D3D::CreateTexture2D(srcAddr, srcFmtWidth, srcHeight, srcFmtWidth, D3DFMT_A8R8G8B8, false);
|
||||
LPDIRECT3DSURFACE9 Rendersurf = NULL;
|
||||
destTexture->GetSurfaceLevel(0,&Rendersurf);
|
||||
D3D::dev->SetDepthStencilSurface(NULL);
|
||||
D3D::dev->SetRenderTarget(0, Rendersurf);
|
||||
|
||||
D3DVIEWPORT9 vp;
|
||||
|
||||
// Stretch picture with increased internal resolution
|
||||
vp.X = 0;
|
||||
vp.Y = 0;
|
||||
vp.Width = srcWidth;
|
||||
vp.Height = srcHeight;
|
||||
vp.MinZ = 0.0f;
|
||||
vp.MaxZ = 1.0f;
|
||||
D3D::dev->SetViewport(&vp);
|
||||
RECT destrect;
|
||||
destrect.bottom = srcHeight;
|
||||
destrect.left = 0;
|
||||
destrect.right = srcWidth;
|
||||
destrect.top = 0;
|
||||
|
||||
RECT sourcerect;
|
||||
sourcerect.bottom = srcHeight;
|
||||
sourcerect.left = 0;
|
||||
sourcerect.right = srcFmtWidth;
|
||||
sourcerect.top = 0;
|
||||
|
||||
D3D::ChangeSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_POINT);
|
||||
D3D::ChangeSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_POINT);
|
||||
|
||||
TextureConversionShader::SetShaderParameters(
|
||||
(float)srcFmtWidth,
|
||||
(float)srcHeight,
|
||||
0.0f ,
|
||||
0.0f,
|
||||
1.0f,
|
||||
1.0f,
|
||||
(float)srcFmtWidth,
|
||||
(float)srcHeight);
|
||||
D3D::drawShadedTexQuad(
|
||||
s_srcTexture,
|
||||
&sourcerect,
|
||||
1 ,
|
||||
1,
|
||||
srcWidth,
|
||||
srcHeight,
|
||||
s_yuyvToRgbProgram,
|
||||
VertexShaderCache::GetSimpleVertexShader(0));
|
||||
|
||||
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MINFILTER);
|
||||
D3D::RefreshSamplerState(0, D3DSAMP_MAGFILTER);
|
||||
D3D::SetTexture(0,NULL);
|
||||
D3D::dev->SetRenderTarget(0, FBManager.GetEFBColorRTSurface());
|
||||
D3D::dev->SetDepthStencilSurface(FBManager.GetEFBDepthRTSurface());
|
||||
Renderer::RestoreAPIState();
|
||||
Rendersurf->Release();
|
||||
s_srcTexture->Release();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -1,45 +1,45 @@
|
||||
// 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 _TEXTURECONVERTER_H_
|
||||
#define _TEXTURECONVERTER_H_
|
||||
|
||||
#include "VideoCommon.h"
|
||||
#include "D3DBase.h"
|
||||
#include "D3DTexture.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "D3DShader.h"
|
||||
|
||||
// Converts textures between formats
|
||||
// TODO: support multiple texture formats
|
||||
namespace TextureConverter
|
||||
{
|
||||
|
||||
void Init();
|
||||
void Shutdown();
|
||||
|
||||
void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt,
|
||||
u32 copyfmt, int bScaleByHalf, const EFBRectangle& source);
|
||||
|
||||
void EncodeToRamYUYV(LPDIRECT3DTEXTURE9 srcTexture, const TargetRectangle& sourceRc,
|
||||
u8* destAddr, int dstWidth, int dstHeight);
|
||||
|
||||
void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, LPDIRECT3DTEXTURE9 destTexture);
|
||||
|
||||
}
|
||||
|
||||
#endif // _TEXTURECONVERTER_H_
|
||||
// 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 _TEXTURECONVERTER_H_
|
||||
#define _TEXTURECONVERTER_H_
|
||||
|
||||
#include "VideoCommon.h"
|
||||
#include "D3DBase.h"
|
||||
#include "D3DTexture.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "D3DShader.h"
|
||||
|
||||
// Converts textures between formats
|
||||
// TODO: support multiple texture formats
|
||||
namespace TextureConverter
|
||||
{
|
||||
|
||||
void Init();
|
||||
void Shutdown();
|
||||
|
||||
void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt,
|
||||
u32 copyfmt, int bScaleByHalf, const EFBRectangle& source);
|
||||
|
||||
void EncodeToRamYUYV(LPDIRECT3DTEXTURE9 srcTexture, const TargetRectangle& sourceRc,
|
||||
u8* destAddr, int dstWidth, int dstHeight);
|
||||
|
||||
void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, LPDIRECT3DTEXTURE9 destTexture);
|
||||
|
||||
}
|
||||
|
||||
#endif // _TEXTURECONVERTER_H_
|
||||
|
@ -1,196 +1,196 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include <windows.h>
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUT DIALOGEX 0, 0, 188, 81
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Dolphin D3D9 Video Plugin"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Close",IDOK,131,60,50,14
|
||||
LTEXT "Code by ector",IDC_STATIC,7,7,85,9
|
||||
LTEXT "Hardware requirements: Radeon 9500 or better, or Geforce FX5200 or better.\nRadeon recommended.",IDC_STATIC,7,19,174,26
|
||||
LTEXT "Will not work correctly on older GPU:s.",IDC_STATIC,7,47,170,8
|
||||
END
|
||||
|
||||
IDD_SETTINGS DIALOGEX 0, 0, 244, 183
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_SYSMENU
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "&Graphics card:",IDC_STATIC,9,9,49,8
|
||||
COMBOBOX IDC_ADAPTER,68,7,162,48,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
CONTROL "&V-Sync",IDC_VSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,68,25,36,8
|
||||
CONTROL "&Widescreen Hack",IDC_WIDESCREEN_HACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,161,25,67,10
|
||||
LTEXT "&Aspect Ratio:",IDC_STATIC,9,40,48,8
|
||||
COMBOBOX IDC_ASPECTRATIO,68,39,89,57,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "&Scale - AA mode:",IDC_STATIC,9,59,59,8
|
||||
COMBOBOX IDC_ANTIALIASMODE,68,59,162,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
CONTROL "&Enable CPU->EFB access ",IDC_EFB_ACCESS_ENABLE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,7,80,94,11
|
||||
GROUPBOX "Safe Texture Cache Mode",IDC_STATIC,109,94,125,27
|
||||
CONTROL "&Safe Texture Cache",IDC_SAFE_TEXTURE_CACHE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,104,80,11
|
||||
CONTROL "Safe",IDC_SAFE_TEXTURE_CACHE_SAFE,"Button",BS_AUTORADIOBUTTON,117,105,27,10
|
||||
CONTROL "Normal",IDC_SAFE_TEXTURE_CACHE_NORMAL,"Button",BS_AUTORADIOBUTTON,154,105,38,10
|
||||
CONTROL "Fast",IDC_SAFE_TEXTURE_CACHE_FAST,"Button",BS_AUTORADIOBUTTON,198,105,30,10
|
||||
CONTROL "",IDC_DXCHK,"RichEdit20W",ES_MULTILINE | ES_READONLY | WS_BORDER | WS_TABSTOP,30,126,186,50
|
||||
END
|
||||
|
||||
IDD_ADVANCED DIALOGEX 0, 0, 244, 200
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_BORDER | WS_SYSMENU
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
GROUPBOX "&Settings",IDC_STATIC,6,7,228,89
|
||||
CONTROL "Overlay FPS counter",IDC_OVERLAYFPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,18,82,8
|
||||
CONTROL "&Overlay some statistics",IDC_OVERLAYSTATS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,155,90,8
|
||||
CONTROL "Show s&hader compilation errors",IDC_SHOWSHADERERRORS,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,169,114,8
|
||||
CONTROL "Enable &Wireframe",IDC_WIREFRAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,48,87,8
|
||||
CONTROL "Disable Fog",IDC_DISABLEFOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,18,78,8
|
||||
CONTROL "Enable Hotkey",IDC_OSDHOTKEY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,33,87,8
|
||||
CONTROL "Enable EFB copy",IDC_ENABLEEFBCOPY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,33,81,8
|
||||
CONTROL "To RAM",IDC_EFBTORAM,"Button",BS_AUTORADIOBUTTON | WS_GROUP,29,44,59,10
|
||||
CONTROL "To Texture",IDC_EFBTOTEX,"Button",BS_AUTORADIOBUTTON,29,57,60,10
|
||||
GROUPBOX "&Data dumping",IDC_STATIC,7,100,228,41
|
||||
CONTROL "Dump &textures",IDC_TEXDUMP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,111,70,9
|
||||
CONTROL "Dump Frames to User/Dump/Frames",IDC_DUMPFRAMES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,125,138,9
|
||||
GROUPBOX "Debugging Tools",IDC_STATIC,7,143,228,51
|
||||
CONTROL "Enable TexFmt Overlay",IDC_TEXFMT_OVERLAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,182,92,10
|
||||
CONTROL "Centered",IDC_TEXFMT_CENTER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,183,52,10
|
||||
CONTROL "Enable XFB",IDC_ENABLEXFB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,71,81,8
|
||||
CONTROL "Enable Real XFB",IDC_ENABLEREALXFB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,71,81,8
|
||||
CONTROL "Use Native Mips",IDC_USENATIVEMIPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,83,67,10
|
||||
END
|
||||
|
||||
IDD_ENHANCEMENTS DIALOGEX 0, 0, 224, 175
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
GROUPBOX "Texture &filtering",IDC_STATIC,7,7,210,60
|
||||
CONTROL "Force &bi/trilinear (breaks video in several Wii games)",IDC_FORCEFILTERING,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,20,192,9
|
||||
CONTROL "Enable 16x &anisotropy filtering",IDC_FORCEANISOTROPY,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,35,110,10
|
||||
CONTROL "Enable hires texture loading",IDC_LOADHIRESTEXTURE,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,50,110,11
|
||||
GROUPBOX "EFB Hacks",IDC_STATIC,7,70,210,27
|
||||
CONTROL "EFB Scaled Copy",IDC_EFBSCALEDCOPY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,80,110,12
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_ABOUT, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 181
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 74
|
||||
END
|
||||
|
||||
IDD_SETTINGS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 237
|
||||
VERTGUIDE, 7
|
||||
VERTGUIDE, 68
|
||||
VERTGUIDE, 109
|
||||
VERTGUIDE, 161
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 176
|
||||
END
|
||||
|
||||
IDD_ADVANCED, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 237
|
||||
VERTGUIDE, 14
|
||||
VERTGUIDE, 29
|
||||
VERTGUIDE, 114
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 195
|
||||
HORZGUIDE, 18
|
||||
HORZGUIDE, 33
|
||||
HORZGUIDE, 49
|
||||
HORZGUIDE, 156
|
||||
END
|
||||
|
||||
IDD_ENHANCEMENTS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 217
|
||||
VERTGUIDE, 16
|
||||
VERTGUIDE, 74
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 168
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include <windows.h>\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include <windows.h>
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUT DIALOGEX 0, 0, 188, 81
|
||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Dolphin D3D9 Video Plugin"
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "Close",IDOK,131,60,50,14
|
||||
LTEXT "Code by ector",IDC_STATIC,7,7,85,9
|
||||
LTEXT "Hardware requirements: Radeon 9500 or better, or Geforce FX5200 or better.\nRadeon recommended.",IDC_STATIC,7,19,174,26
|
||||
LTEXT "Will not work correctly on older GPU:s.",IDC_STATIC,7,47,170,8
|
||||
END
|
||||
|
||||
IDD_SETTINGS DIALOGEX 0, 0, 244, 183
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_VISIBLE | WS_BORDER | WS_SYSMENU
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "&Graphics card:",IDC_STATIC,9,9,49,8
|
||||
COMBOBOX IDC_ADAPTER,68,7,162,48,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
CONTROL "&V-Sync",IDC_VSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,68,25,36,8
|
||||
CONTROL "&Widescreen Hack",IDC_WIDESCREEN_HACK,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,161,25,67,10
|
||||
LTEXT "&Aspect Ratio:",IDC_STATIC,9,40,48,8
|
||||
COMBOBOX IDC_ASPECTRATIO,68,39,89,57,CBS_DROPDOWNLIST | CBS_SORT | WS_VSCROLL | WS_TABSTOP
|
||||
LTEXT "&Scale - AA mode:",IDC_STATIC,9,59,59,8
|
||||
COMBOBOX IDC_ANTIALIASMODE,68,59,162,73,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
|
||||
CONTROL "&Enable CPU->EFB access ",IDC_EFB_ACCESS_ENABLE,"Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,7,80,94,11
|
||||
GROUPBOX "Safe Texture Cache Mode",IDC_STATIC,109,94,125,27
|
||||
CONTROL "&Safe Texture Cache",IDC_SAFE_TEXTURE_CACHE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,104,80,11
|
||||
CONTROL "Safe",IDC_SAFE_TEXTURE_CACHE_SAFE,"Button",BS_AUTORADIOBUTTON,117,105,27,10
|
||||
CONTROL "Normal",IDC_SAFE_TEXTURE_CACHE_NORMAL,"Button",BS_AUTORADIOBUTTON,154,105,38,10
|
||||
CONTROL "Fast",IDC_SAFE_TEXTURE_CACHE_FAST,"Button",BS_AUTORADIOBUTTON,198,105,30,10
|
||||
CONTROL "",IDC_DXCHK,"RichEdit20W",ES_MULTILINE | ES_READONLY | WS_BORDER | WS_TABSTOP,30,126,186,50
|
||||
END
|
||||
|
||||
IDD_ADVANCED DIALOGEX 0, 0, 244, 200
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_BORDER | WS_SYSMENU
|
||||
FONT 8, "MS Shell Dlg", 0, 0, 0x0
|
||||
BEGIN
|
||||
GROUPBOX "&Settings",IDC_STATIC,6,7,228,89
|
||||
CONTROL "Overlay FPS counter",IDC_OVERLAYFPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,18,82,8
|
||||
CONTROL "&Overlay some statistics",IDC_OVERLAYSTATS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,155,90,8
|
||||
CONTROL "Show s&hader compilation errors",IDC_SHOWSHADERERRORS,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,169,114,8
|
||||
CONTROL "Enable &Wireframe",IDC_WIREFRAME,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,48,87,8
|
||||
CONTROL "Disable Fog",IDC_DISABLEFOG,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,18,78,8
|
||||
CONTROL "Enable Hotkey",IDC_OSDHOTKEY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,33,87,8
|
||||
CONTROL "Enable EFB copy",IDC_ENABLEEFBCOPY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,33,81,8
|
||||
CONTROL "To RAM",IDC_EFBTORAM,"Button",BS_AUTORADIOBUTTON | WS_GROUP,29,44,59,10
|
||||
CONTROL "To Texture",IDC_EFBTOTEX,"Button",BS_AUTORADIOBUTTON,29,57,60,10
|
||||
GROUPBOX "&Data dumping",IDC_STATIC,7,100,228,41
|
||||
CONTROL "Dump &textures",IDC_TEXDUMP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,111,70,9
|
||||
CONTROL "Dump Frames to User/Dump/Frames",IDC_DUMPFRAMES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,125,138,9
|
||||
GROUPBOX "Debugging Tools",IDC_STATIC,7,143,228,51
|
||||
CONTROL "Enable TexFmt Overlay",IDC_TEXFMT_OVERLAY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,182,92,10
|
||||
CONTROL "Centered",IDC_TEXFMT_CENTER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,183,52,10
|
||||
CONTROL "Enable XFB",IDC_ENABLEXFB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,71,81,8
|
||||
CONTROL "Enable Real XFB",IDC_ENABLEREALXFB,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,114,71,81,8
|
||||
CONTROL "Use Native Mips",IDC_USENATIVEMIPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,14,83,67,10
|
||||
END
|
||||
|
||||
IDD_ENHANCEMENTS DIALOGEX 0, 0, 224, 175
|
||||
STYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD | WS_SYSMENU
|
||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||
BEGIN
|
||||
GROUPBOX "Texture &filtering",IDC_STATIC,7,7,210,60
|
||||
CONTROL "Force &bi/trilinear (breaks video in several Wii games)",IDC_FORCEFILTERING,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,20,192,9
|
||||
CONTROL "Enable 16x &anisotropy filtering",IDC_FORCEANISOTROPY,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,35,110,10
|
||||
CONTROL "Enable hires texture loading",IDC_LOADHIRESTEXTURE,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,50,110,11
|
||||
GROUPBOX "EFB Hacks",IDC_STATIC,7,70,210,27
|
||||
CONTROL "EFB Scaled Copy",IDC_EFBSCALEDCOPY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,80,110,12
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO
|
||||
BEGIN
|
||||
IDD_ABOUT, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 181
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 74
|
||||
END
|
||||
|
||||
IDD_SETTINGS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 237
|
||||
VERTGUIDE, 7
|
||||
VERTGUIDE, 68
|
||||
VERTGUIDE, 109
|
||||
VERTGUIDE, 161
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 176
|
||||
END
|
||||
|
||||
IDD_ADVANCED, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 237
|
||||
VERTGUIDE, 14
|
||||
VERTGUIDE, 29
|
||||
VERTGUIDE, 114
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 195
|
||||
HORZGUIDE, 18
|
||||
HORZGUIDE, 33
|
||||
HORZGUIDE, 49
|
||||
HORZGUIDE, 156
|
||||
END
|
||||
|
||||
IDD_ENHANCEMENTS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 217
|
||||
VERTGUIDE, 16
|
||||
VERTGUIDE, 74
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 168
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"#include <windows.h>\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
|
Reference in New Issue
Block a user