From 8f035ae40a39bba6e7ab4c65077b97806d535c7c Mon Sep 17 00:00:00 2001 From: donkopunchstania Date: Thu, 2 Dec 2010 05:38:48 +0000 Subject: [PATCH] Create a config dialog. Add dumping TEV texture fetches. Better TEV stage dumping. Byteswap indexed XF loading. Remove scaling texture coordinates in the HW rasterizer because that has already been done by the time they reach the rasterizer. Increase storage for clipper. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6506 8ced0084-cf51-0410-be5f-012b33b47a6e --- .../Plugin_VideoSoftware/CMakeLists.txt | 1 + .../Plugin_VideoSoftware.vcproj | 8 + .../Plugin_VideoSoftware/Src/Clipper.cpp | 15 +- .../Plugin_VideoSoftware/Src/DebugUtil.cpp | 51 ++++++- .../Plugin_VideoSoftware/Src/DebugUtil.h | 5 +- .../Plugin_VideoSoftware/Src/EfbCopy.cpp | 12 +- .../Plugin_VideoSoftware/Src/HwRasterizer.cpp | 15 +- .../Plugin_VideoSoftware/Src/Renderer.cpp | 4 +- .../Plugin_VideoSoftware/Src/SConscript | 1 + .../Plugins/Plugin_VideoSoftware/Src/Tev.cpp | 39 ++++- Source/Plugins/Plugin_VideoSoftware/Src/Tev.h | 7 + .../Plugin_VideoSoftware/Src/VideoConfig.cpp | 49 ++++-- .../Plugin_VideoSoftware/Src/VideoConfig.h | 18 ++- .../Src/VideoConfigDialog.cpp | 143 ++++++++++++++++++ .../Src/VideoConfigDialog.h | 83 ++++++++++ .../Plugin_VideoSoftware/Src/XFMemLoader.cpp | 7 +- .../Plugins/Plugin_VideoSoftware/Src/main.cpp | 12 +- 17 files changed, 419 insertions(+), 51 deletions(-) create mode 100644 Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.cpp create mode 100644 Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.h diff --git a/Source/Plugins/Plugin_VideoSoftware/CMakeLists.txt b/Source/Plugins/Plugin_VideoSoftware/CMakeLists.txt index dd34855536..e7f3cab500 100644 --- a/Source/Plugins/Plugin_VideoSoftware/CMakeLists.txt +++ b/Source/Plugins/Plugin_VideoSoftware/CMakeLists.txt @@ -22,6 +22,7 @@ set(SRCS Src/BPMemLoader.cpp Src/VertexFormatConverter.cpp Src/VertexLoader.cpp Src/VideoConfig.cpp + Src/VideoConfigDialog.cpp Src/XFMemLoader.cpp) set(LIBS videocommon diff --git a/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcproj b/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcproj index 4ff6a9cad7..4cc4c0943d 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcproj +++ b/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcproj @@ -663,6 +663,14 @@ RelativePath=".\Src\VideoConfig.h" > + + + + diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.cpp index 4af6f2c886..3280fbd58c 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Clipper.cpp @@ -59,13 +59,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. namespace Clipper { - float m_ViewOffset[3]; - OutputVertexData ClippedVertices[18]; - OutputVertexData *Vertices[21]; + enum { NUM_CLIPPED_VERTICES = 33, NUM_INDICES = NUM_CLIPPED_VERTICES + 3 }; + + float m_ViewOffset[3]; + OutputVertexData ClippedVertices[NUM_CLIPPED_VERTICES]; + OutputVertexData *Vertices[NUM_INDICES]; void Init() { - for (int i = 0; i < 18; ++i) + for (int i = 0; i < NUM_CLIPPED_VERTICES; ++i) Vertices[i+3] = &ClippedVertices[i]; } @@ -282,7 +284,7 @@ namespace Clipper if(!CullTest(v0, v1, v2, backface)) return; - int indices[21] = { 0, 1, 2, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, + int indices[NUM_INDICES] = { 0, 1, 2, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG, SKIP_FLAG }; int numIndices = 3; @@ -304,7 +306,8 @@ namespace Clipper for(int i = 0; i+3 <= numIndices; i+=3) { - if(indices[i] != SKIP_FLAG) + _assert_(i < NUM_INDICES); + if(indices[i] != SKIP_FLAG) { PerspectiveDivide(Vertices[indices[i]]); PerspectiveDivide(Vertices[indices[i+1]]); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/DebugUtil.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/DebugUtil.cpp index 4ead73e582..a4313968c6 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/DebugUtil.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/DebugUtil.cpp @@ -34,10 +34,16 @@ namespace DebugUtil { u32 skipFrames = 0; -const int NumObjectBuffers = 32; -u8 ObjectBuffer[NumObjectBuffers][EFB_WIDTH*EFB_HEIGHT*4]; +bool drawingHwTriangles = false; + +enum { NumObjectBuffers = 40}; + +u32 ObjectBuffer[NumObjectBuffers][EFB_WIDTH*EFB_HEIGHT]; +u32 TempBuffer[NumObjectBuffers]; + bool DrawnToBuffer[NumObjectBuffers]; const char* ObjectBufferName[NumObjectBuffers]; +int BufferBase[NumObjectBuffers]; void Init() { @@ -46,6 +52,7 @@ void Init() memset(ObjectBuffer[i], 0, sizeof(ObjectBuffer[i])); DrawnToBuffer[i] = false; ObjectBufferName[i] = 0; + BufferBase[i] = 0; } } @@ -168,10 +175,12 @@ void DumpDepth(const char* filename) delete []data; } -void DrawObjectBuffer(s16 x, s16 y, u8 *color, int buffer, const char *name) +void DrawObjectBuffer(s16 x, s16 y, u8 *color, int bufferBase, int subBuffer, const char *name) { - u32 offset = (x + y * EFB_WIDTH) * 4; - u8 *dst = &ObjectBuffer[buffer][offset]; + int buffer = bufferBase + subBuffer; + + u32 offset = (x + y * EFB_WIDTH) * 4; + u8 *dst = (u8*)&ObjectBuffer[buffer][offset]; *(dst++) = color[2]; *(dst++) = color[1]; *(dst++) = color[0]; @@ -179,6 +188,28 @@ void DrawObjectBuffer(s16 x, s16 y, u8 *color, int buffer, const char *name) DrawnToBuffer[buffer] = true; ObjectBufferName[buffer] = name; + BufferBase[buffer] = bufferBase; +} + +void DrawTempBuffer(u8 *color, int buffer) +{ + u8 *dst = (u8*)&TempBuffer[buffer]; + *(dst++) = color[2]; + *(dst++) = color[1]; + *(dst++) = color[0]; + *(dst++) = color[3]; +} + +void CopyTempBuffer(s16 x, s16 y, int bufferBase, int subBuffer, const char *name) +{ + int buffer = bufferBase + subBuffer; + + u32 offset = (x + y * EFB_WIDTH); + ObjectBuffer[buffer][offset] = TempBuffer[buffer]; + + DrawnToBuffer[buffer] = true; + ObjectBufferName[buffer] = name; + BufferBase[buffer] = bufferBase; } void OnObjectBegin() @@ -189,7 +220,10 @@ void OnObjectBegin() DumpActiveTextures(); if (g_Config.bHwRasterizer) + { HwRasterizer::BeginTriangles(); + drawingHwTriangles = true; + } } } @@ -200,8 +234,11 @@ void OnObjectEnd() if (g_Config.bDumpObjects && stats.thisFrame.numDrawnObjects >= g_Config.drawStart && stats.thisFrame.numDrawnObjects < g_Config.drawEnd) DumpEfb(StringFromFormat("%sobject%i.tga", File::GetUserPath(D_DUMPFRAMES_IDX), stats.thisFrame.numDrawnObjects).c_str()); - if (g_Config.bHwRasterizer) + if (g_Config.bHwRasterizer || drawingHwTriangles) + { HwRasterizer::EndTriangles(); + drawingHwTriangles = false; + } for (int i = 0; i < NumObjectBuffers; i++) { @@ -209,7 +246,7 @@ void OnObjectEnd() { DrawnToBuffer[i] = false; (void)SaveTGA(StringFromFormat("%sobject%i_%s(%i).tga", File::GetUserPath(D_DUMPFRAMES_IDX), - stats.thisFrame.numDrawnObjects, ObjectBufferName[i], i).c_str(), EFB_WIDTH, EFB_HEIGHT, ObjectBuffer[i]); + stats.thisFrame.numDrawnObjects, ObjectBufferName[i], i - BufferBase[i]).c_str(), EFB_WIDTH, EFB_HEIGHT, ObjectBuffer[i]); memset(ObjectBuffer[i], 0, sizeof(ObjectBuffer[i])); } } diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/DebugUtil.h b/Source/Plugins/Plugin_VideoSoftware/Src/DebugUtil.h index 02252f3868..4b2f0b86aa 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/DebugUtil.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/DebugUtil.h @@ -31,7 +31,10 @@ namespace DebugUtil void OnFrameEnd(); - void DrawObjectBuffer(s16 x, s16 y, u8 *color, int buffer, const char *name); + void DrawObjectBuffer(s16 x, s16 y, u8 *color, int bufferBase, int subBuffer, const char *name); + + void DrawTempBuffer(u8 *color, int buffer); + void CopyTempBuffer(s16 x, s16 y, int bufferBase, int subBuffer, const char *name); } #endif diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/EfbCopy.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/EfbCopy.cpp index 28a9497b1a..d7d77d981f 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/EfbCopy.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/EfbCopy.cpp @@ -26,13 +26,16 @@ #include "DebugUtil.h" #include "HwRasterizer.h" #include "CommandProcessor.h" +#include "GLUtil.h" namespace EfbCopy { void CopyToXfb() { - if (!g_Config.bHwRasterizer) + OpenGL_Update(); // just updates the render window position and the backbuffer size + + if (!g_Config.bHwRasterizer) { // copy to open gl for rendering EfbInterface::UpdateColorTexture(); @@ -45,9 +48,12 @@ namespace EfbCopy void CopyToRam() { - u8 *dest_ptr = g_VideoInitialize.pGetMemoryPointer(bpmem.copyTexDest << 5); + if (!g_Config.bHwRasterizer) + { + u8 *dest_ptr = g_VideoInitialize.pGetMemoryPointer(bpmem.copyTexDest << 5); - TextureEncoder::Encode(dest_ptr); + TextureEncoder::Encode(dest_ptr); + } } void ClearEfb() diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/HwRasterizer.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/HwRasterizer.cpp index 71a5a3669f..3d335f366d 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/HwRasterizer.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/HwRasterizer.cpp @@ -32,8 +32,6 @@ namespace HwRasterizer { float efbHalfWidth; float efbHalfHeight; - float texWidth; - float texHeight; bool hasTexture; u8 *temp; @@ -54,9 +52,6 @@ namespace HwRasterizer TexCacheEntry &cacheEntry = textures[imageAddr]; cacheEntry.Update(); - texWidth = (float)(bpmem.texcoords[0].s.scale_minus_1 + 1); - texHeight = (float)(bpmem.texcoords[0].t.scale_minus_1 + 1); - glBindTexture(GL_TEXTURE_RECTANGLE_ARB, cacheEntry.texture); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MAG_FILTER, texUnit.texMode0[0].mag_filter ? GL_LINEAR : GL_NEAREST); glTexParameteri(GL_TEXTURE_RECTANGLE_ARB, GL_TEXTURE_MIN_FILTER, (texUnit.texMode0[0].min_filter >= 4) ? GL_LINEAR : GL_NEAREST); @@ -90,8 +85,14 @@ namespace HwRasterizer void DrawTextureVertex(OutputVertexData *v) { - glTexCoord2f(v->texCoords[0].x * texWidth, v->texCoords[0].y * texHeight); - glVertex3f(v->screenPosition.x / efbHalfWidth - 1.0f, 1.0f - v->screenPosition.y / efbHalfHeight, v->screenPosition.z); + float s = v->texCoords[0].x; + float t = v->texCoords[0].y; + glTexCoord2f(s, t); + + float x = (v->screenPosition.x / efbHalfWidth) - 1.0f; + float y = 1.0f - (v->screenPosition.y / efbHalfHeight); + float z = v->screenPosition.z; + glVertex3f(x, y, z); } void DrawTriangleFrontFace(OutputVertexData *v0, OutputVertexData *v1, OutputVertexData *v2) diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.cpp index 52575900f3..360ee70789 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.cpp @@ -149,9 +149,7 @@ void Renderer::DrawDebugText() void Renderer::DrawTexture(u8 *texture, int width, int height) { - OpenGL_Update(); // just updates the render window position and the backbuffer size - - GLsizei glWidth = (GLsizei)OpenGL_GetBackbufferWidth(); + GLsizei glWidth = (GLsizei)OpenGL_GetBackbufferWidth(); GLsizei glHeight = (GLsizei)OpenGL_GetBackbufferHeight(); // Update GLViewPort diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SConscript b/Source/Plugins/Plugin_VideoSoftware/Src/SConscript index 64d9f45892..b15c94c7cb 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SConscript +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SConscript @@ -31,6 +31,7 @@ files = [ 'VertexFormatConverter.cpp', 'VertexLoader.cpp', 'VideoConfig.cpp', + 'VideoConfigDialog.cpp', 'XFMemLoader.cpp', ] diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp index c0d4904f71..f277948fba 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.cpp @@ -26,6 +26,12 @@ #include +#ifdef _DEBUG +#define ALLOW_TEV_DUMPS 1 +#else +#define ALLOW_TEV_DUMPS 0 +#endif + void Tev::Init() { FixedConstants[0] = 0; @@ -592,11 +598,11 @@ void Tev::Draw() TextureSampler::Sample(Uv[texcoordSel].s >> scaleS, Uv[texcoordSel].t >> scaleT, IndirectLod[stageNum], IndirectLinear[stageNum], texmap, IndirectTex[stageNum]); -#ifdef _DEBUG +#if ALLOW_TEV_DUMPS if (g_Config.bDumpTevStages) { u8 stage[4] = {(u8)IndirectTex[stageNum][3], (u8)IndirectTex[stageNum][2], (u8)IndirectTex[stageNum][1], 255}; - DebugUtil::DrawObjectBuffer(Position[0], Position[1], stage, 16+stageNum, "Ind"); + DebugUtil::DrawTempBuffer(stage, INDIRECT + stageNum); } #endif } @@ -624,6 +630,11 @@ void Tev::Draw() TextureSampler::Sample(TexCoord.s, TexCoord.t, TextureLod[stageNum], TextureLinear[stageNum], texmap, texel); +#if ALLOW_TEV_DUMPS + if (g_Config.bDumpTevTextureFetches) + DebugUtil::DrawTempBuffer(texel, DIRECT_TFETCH + stageNum); +#endif + int swaptable = ac.tswap * 2; TexColor[0] = texel[bpmem.tevksel[swaptable].swap1]; @@ -673,11 +684,11 @@ void Tev::Draw() else Reg[ac.dest][ALP_C] = Clamp1024(Reg[ac.dest][ALP_C]); -#ifdef _DEBUG +#if ALLOW_TEV_DUMPS if (g_Config.bDumpTevStages) { u8 stage[4] = {(u8)Reg[0][0], (u8)Reg[0][1], (u8)Reg[0][2], (u8)Reg[0][3]}; - DebugUtil::DrawObjectBuffer(Position[0], Position[1], stage, stageNum, "Stage"); + DebugUtil::DrawTempBuffer(stage, DIRECT + stageNum); } #endif } @@ -775,6 +786,26 @@ void Tev::Draw() return; } +#if ALLOW_TEV_DUMPS + if (g_Config.bDumpTevStages) + { + for (u32 i = 0; i < bpmem.genMode.numindstages; ++i) + DebugUtil::CopyTempBuffer(Position[0], Position[1], INDIRECT, i, "Indirect"); + for (u32 i = 0; i <= bpmem.genMode.numtevstages; ++i) + DebugUtil::CopyTempBuffer(Position[0], Position[1], DIRECT, i, "Stage"); + } + + if (g_Config.bDumpTevTextureFetches) + { + for (u32 i = 0; i <= bpmem.genMode.numtevstages; ++i) + { + TwoTevStageOrders &order = bpmem.tevorders[i >> 1]; + if (order.getEnable(i & 1)) + DebugUtil::CopyTempBuffer(Position[0], Position[1], DIRECT_TFETCH, i, "TFetch"); + } + } +#endif + INCSTAT(stats.thisFrame.tevPixelsOut); EfbInterface::BlendTev(Position[0], Position[1], output); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.h b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.h index 4fc2b42502..81da736952 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Tev.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Tev.h @@ -55,6 +55,13 @@ class Tev u8 m_ScaleLShiftLUT[4]; u8 m_ScaleRShiftLUT[4]; + enum BufferBase + { + DIRECT = 0, + DIRECT_TFETCH = 16, + INDIRECT = 32 + }; + void SetRasColor(int colorChan, int swaptable); void DrawColorRegular(TevStageCombiner::ColorCombiner &cc); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfig.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfig.cpp index b56f77479e..746762901b 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfig.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfig.cpp @@ -19,46 +19,73 @@ #include "IniFile.h" #include "VideoConfig.h" -Config g_Config; +VideoConfig g_Config; -Config::Config() +VideoConfig::VideoConfig() { bFullscreen = false; bHideCursor = false; renderToMainframe = false; + bHwRasterizer = false; + bShowStats = false; + bDumpTextures = false; bDumpObjects = false; bDumpFrames = false; - bDumpTevStages = false; - bHwRasterizer = false; + bDumpTevStages = false; + bDumpTevTextureFetches = false; drawStart = 0; drawEnd = 100000; } -void Config::Load() +void VideoConfig::Load(const char* ini_file) { std::string temp; IniFile iniFile; - iniFile.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_software.ini").c_str()); + iniFile.Load(ini_file); iniFile.Get("Hardware", "Fullscreen", &bFullscreen, 0); // Hardware iniFile.Get("Hardware", "RenderToMainframe", &renderToMainframe, false); + + iniFile.Get("Rendering", "HwRasterizer", &bHwRasterizer, false); + + iniFile.Get("Info", "ShowStats", &bShowStats, false); + + iniFile.Get("Utility", "DumpTexture", &bDumpTextures, false); + iniFile.Get("Utility", "DumpObjects", &bDumpObjects, false); + iniFile.Get("Utility", "DumpFrames", &bDumpFrames, false); + iniFile.Get("Utility", "DumpTevStages", &bDumpTevStages, false); + iniFile.Get("Utility", "DumpTevTexFetches", &bDumpTevTextureFetches, false); + + iniFile.Get("Misc", "DrawStart", &drawStart, 0); + iniFile.Get("Misc", "DrawEnd", &drawEnd, 100000); } - - -void Config::Save() +void VideoConfig::Save(const char* ini_file) { IniFile iniFile; - iniFile.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_software.ini").c_str()); + iniFile.Load(ini_file); iniFile.Set("Hardware", "Fullscreen", bFullscreen); iniFile.Set("Hardware", "RenderToMainframe", renderToMainframe); + + iniFile.Set("Rendering", "HwRasterizer", bHwRasterizer); + + iniFile.Set("Info", "ShowStats", bShowStats); + + iniFile.Set("Utility", "DumpTexture", bDumpTextures); + iniFile.Set("Utility", "DumpObjects", bDumpObjects); + iniFile.Set("Utility", "DumpFrames", bDumpFrames); + iniFile.Set("Utility", "DumpTevStages", bDumpTevStages); + iniFile.Set("Utility", "DumpTevTexFetches", bDumpTevTextureFetches); + + iniFile.Set("Misc", "DrawStart", drawStart); + iniFile.Set("Misc", "DrawEnd", drawEnd); - iniFile.Save((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_opengl.ini").c_str()); + iniFile.Save(ini_file); } diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfig.h b/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfig.h index e6c88e6180..fe52b494a0 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfig.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfig.h @@ -23,29 +23,33 @@ #define STATISTICS 1 // NEVER inherit from this class. -struct Config : NonCopyable +struct VideoConfig : NonCopyable { - Config(); - void Load(); - void Save(); + VideoConfig(); + void Load(const char* ini_file); + void Save(const char* ini_file); // General bool bFullscreen; bool bHideCursor; bool renderToMainframe; + bool bHwRasterizer; + bool bShowStats; + bool bDumpTextures; bool bDumpObjects; bool bDumpFrames; - bool bDumpTevStages; - bool bHwRasterizer; + // Debug only + bool bDumpTevStages; + bool bDumpTevTextureFetches; u32 drawStart; u32 drawEnd; }; -extern Config g_Config; +extern VideoConfig g_Config; #endif // _PLUGIN_VIDEOSOFTWARE_CONFIG_H_ diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.cpp new file mode 100644 index 0000000000..aceaf0ec58 --- /dev/null +++ b/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.cpp @@ -0,0 +1,143 @@ +// 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 "VideoConfigDialog.h" + +#include "FileUtil.h" + +#define _connect_macro_(b, f, c, s) (b)->Connect(wxID_ANY, (c), wxCommandEventHandler( f ), (wxObject*)0, (wxEvtHandler*)s) + +// template instantiation +template class BoolSetting; + +template <> +SettingCheckBox::BoolSetting(wxWindow* parent, const wxString& label, bool &setting, bool reverse, long style) : + wxCheckBox(parent, -1, label, wxDefaultPosition, wxDefaultSize, style), + m_setting(setting), + m_reverse(reverse) +{ + SetValue(m_setting ^ m_reverse); + _connect_macro_(this, SettingCheckBox::UpdateValue, wxEVT_COMMAND_CHECKBOX_CLICKED, this); +} + +template +IntegerSetting::IntegerSetting(wxWindow* parent, const wxString& label, T& setting, int minVal, int maxVal, long style) : + wxSpinCtrl(parent, -1, label, wxDefaultPosition, wxDefaultSize, style), + m_setting(setting) +{ + SetRange(minVal, maxVal); + SetValue(m_setting); + _connect_macro_(this, IntegerSetting::UpdateValue, wxEVT_COMMAND_SPINCTRL_UPDATED, this); +} + + +VideoConfigDialog::VideoConfigDialog(wxWindow* parent, const std::string& title, const std::string& _ininame) : + wxDialog(parent, -1, + wxString(wxT("Dolphin ")).append(wxString::FromAscii(title.c_str())).append(wxT(" Graphics Configuration")), + wxDefaultPosition, wxDefaultSize), + vconfig(g_Config), + ininame(_ininame) +{ + vconfig.Load((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str()); + + wxNotebook* const notebook = new wxNotebook(this, -1, wxDefaultPosition, wxDefaultSize); + + // -- GENERAL -- + { + wxPanel* const page_general= new wxPanel(notebook, -1, wxDefaultPosition); + notebook->AddPage(page_general, wxT("General")); + wxBoxSizer* const szr_general = new wxBoxSizer(wxVERTICAL); + + // - rendering + { + wxStaticBoxSizer* const group_rendering = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Rendering")); + szr_general->Add(group_rendering, 0, wxEXPAND | wxALL, 5); + wxGridSizer* const szr_rendering = new wxGridSizer(2, 5, 5); + group_rendering->Add(szr_rendering, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + + szr_rendering->Add(new SettingCheckBox(page_general, wxT("Hardware rasterization"), vconfig.bHwRasterizer)); + } + + // - info + { + wxStaticBoxSizer* const group_info = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Overlay Information")); + szr_general->Add(group_info, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + wxGridSizer* const szr_info = new wxGridSizer(2, 5, 5); + group_info->Add(szr_info, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + + szr_info->Add(new SettingCheckBox(page_general, wxT("Various Statistics"), vconfig.bShowStats)); + } + + // - utility + { + wxStaticBoxSizer* const group_utility = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Utility")); + szr_general->Add(group_utility, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + wxGridSizer* const szr_utility = new wxGridSizer(2, 5, 5); + group_utility->Add(szr_utility, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + + szr_utility->Add(new SettingCheckBox(page_general, wxT("Dump Textures"), vconfig.bDumpTextures)); + szr_utility->Add(new SettingCheckBox(page_general, wxT("Dump Objects"), vconfig.bDumpObjects)); + szr_utility->Add(new SettingCheckBox(page_general, wxT("Dump Frames"), vconfig.bDumpFrames)); + + // - debug only + wxStaticBoxSizer* const group_debug_only_utility = new wxStaticBoxSizer(wxHORIZONTAL, page_general, wxT("Debug Only")); + group_utility->Add(group_debug_only_utility, 0, wxEXPAND | wxBOTTOM, 5); + wxGridSizer* const szr_debug_only_utility = new wxGridSizer(2, 5, 5); + group_debug_only_utility->Add(szr_debug_only_utility, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + + szr_debug_only_utility->Add(new SettingCheckBox(page_general, wxT("Dump TEV Stages"), vconfig.bDumpTevStages)); + szr_debug_only_utility->Add(new SettingCheckBox(page_general, wxT("Dump Texture Fetches"), vconfig.bDumpTevTextureFetches)); + } + + // - misc + { + wxStaticBoxSizer* const group_misc = new wxStaticBoxSizer(wxVERTICAL, page_general, wxT("Drawn Object Range")); + szr_general->Add(group_misc, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + wxFlexGridSizer* const szr_misc = new wxFlexGridSizer(2, 5, 5); + group_misc->Add(szr_misc, 1, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 5); + + szr_misc->Add(new U32Setting(page_general, wxT("Start"), vconfig.drawStart, 0, 100000)); + szr_misc->Add(new U32Setting(page_general, wxT("End"), vconfig.drawEnd, 0, 100000)); + } + + page_general->SetSizerAndFit(szr_general); + } + + wxButton* const btn_close = new wxButton(this, -1, wxT("Close"), wxDefaultPosition); + _connect_macro_(btn_close, VideoConfigDialog::Event_ClickClose, wxEVT_COMMAND_BUTTON_CLICKED, this); + + Connect(-1, wxEVT_CLOSE_WINDOW, wxCloseEventHandler(VideoConfigDialog::Event_Close), (wxObject*)0, this); + + wxBoxSizer* const szr_main = new wxBoxSizer(wxVERTICAL); + szr_main->Add(notebook, 1, wxEXPAND | wxALL, 5); + szr_main->Add(btn_close, 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 5); + + SetSizerAndFit(szr_main); + Center(); +} + +void VideoConfigDialog::Event_ClickClose(wxCommandEvent&) +{ + Close(); +} + +void VideoConfigDialog::Event_Close(wxCloseEvent& ev) +{ + g_Config.Save((File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini").c_str()); + + ev.Skip(); +} diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.h b/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.h new file mode 100644 index 0000000000..4611cd7cf9 --- /dev/null +++ b/Source/Plugins/Plugin_VideoSoftware/Src/VideoConfigDialog.h @@ -0,0 +1,83 @@ +// 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 _PLUGIN_VIDEOSOFTWARE_CONFIG_DIAG_H_ +#define _PLUGIN_VIDEOSOFTWARE_CONFIG_DIAG_H_ + +#include +#include + +#include "VideoConfig.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +template +class BoolSetting : public W +{ +public: + BoolSetting(wxWindow* parent, const wxString& label, bool &setting, bool reverse = false, long style = 0); + + void UpdateValue(wxCommandEvent& ev) + { + m_setting = (ev.GetInt() != 0) ^ m_reverse; + ev.Skip(); + } +private: + bool& m_setting; + const bool m_reverse; +}; + +template +class IntegerSetting : public wxSpinCtrl +{ +public: + IntegerSetting(wxWindow* parent, const wxString& label, T& setting, int minVal, int maxVal, long style = 0); + + void UpdateValue(wxCommandEvent& ev) + { + m_setting = ev.GetInt(); + ev.Skip(); + } +private: + T& m_setting; +}; + +typedef BoolSetting SettingCheckBox; +typedef IntegerSetting U32Setting; + +class VideoConfigDialog : public wxDialog +{ +public: + VideoConfigDialog(wxWindow* parent, const std::string &title, const std::string& ininame); + +protected: + void Event_ClickClose(wxCommandEvent&); + void Event_Close(wxCloseEvent&); + + VideoConfig& vconfig; + std::string ininame; +}; + +#endif diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/XFMemLoader.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/XFMemLoader.cpp index eea3ba249b..371c893743 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/XFMemLoader.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/XFMemLoader.cpp @@ -92,5 +92,10 @@ void LoadIndexedXF(u32 val, int array) u32 *pData = (u32*)g_VideoInitialize.pGetMemoryPointer(arraybases[array] + arraystrides[array]*index); - LoadXFReg(size, address, pData); + // byteswap data + u32 buffer[16]; + for (int i = 0; i < size; ++i) + buffer[i] = Common::swap32(*(pData + i)); + + LoadXFReg(size, address, buffer); } diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/main.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/main.cpp index 1c4715e9f3..72c7d82b59 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/main.cpp @@ -19,6 +19,10 @@ #include "Common.h" #include "pluginspecs_video.h" +#if defined(HAVE_WX) && HAVE_WX +#include "VideoConfigDialog.h" +#endif // HAVE_WX + #include "CommandProcessor.h" #include "OpcodeDecoder.h" #include "VideoConfig.h" @@ -34,6 +38,7 @@ #include "LogManager.h" #include "EfbInterface.h" #include "DebugUtil.h" +#include "FileUtil.h" PLUGIN_GLOBALS* globals = NULL; @@ -68,6 +73,11 @@ void *DllDebugger(void *_hParent, bool Show) void DllConfig(void *_hParent) { +#if defined(HAVE_WX) && HAVE_WX + VideoConfigDialog* const diag = new VideoConfigDialog((wxWindow*)_hParent, "Software", "gfx_software"); + diag->ShowModal(); + diag->Destroy(); +#endif } void Initialize(void *init) @@ -75,7 +85,7 @@ void Initialize(void *init) SVideoInitialize *_pVideoInitialize = (SVideoInitialize*)init; g_VideoInitialize = *_pVideoInitialize; - g_Config.Load(); + g_Config.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_software.ini").c_str()); InitBPMemory(); InitXFMemory();