diff --git a/Source/Core/Common/Common.vcproj b/Source/Core/Common/Common.vcproj index 378c7dfb3f98..dfc1b1fb8880 100644 --- a/Source/Core/Common/Common.vcproj +++ b/Source/Core/Common/Common.vcproj @@ -1,7 +1,7 @@ - - - - - - - - - - - - - - - - - - - - @@ -641,14 +601,6 @@ RelativePath=".\Src\DebugInterface.h" > - - - - @@ -761,6 +713,10 @@ RelativePath=".\Src\OpenCL.h" > + + @@ -897,6 +853,14 @@ RelativePath=".\Src\Version.cpp" > + + + + diff --git a/Source/Core/Common/Common.vcxproj b/Source/Core/Common/Common.vcxproj index 4a15c7d641a8..2e8e099c6532 100644 --- a/Source/Core/Common/Common.vcxproj +++ b/Source/Core/Common/Common.vcxproj @@ -242,7 +242,6 @@ - @@ -256,9 +255,6 @@ - - - Create @@ -275,6 +271,7 @@ + @@ -299,7 +296,6 @@ - @@ -316,9 +312,7 @@ - - - + diff --git a/Source/Core/Common/Src/DynamicLibrary.cpp b/Source/Core/Common/Src/DynamicLibrary.cpp deleted file mode 100644 index 9ffdd04925bf..000000000000 --- a/Source/Core/Common/Src/DynamicLibrary.cpp +++ /dev/null @@ -1,166 +0,0 @@ -// 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/ - -/* - All plugins from Core > Plugins are loaded and unloaded with this class when - Dolpin is started and stopped. -*/ - -#include // System -#ifdef _WIN32 -#include -#else -#include -#include -#endif - -#include "Common.h" // Local -#include "FileUtil.h" -#include "StringUtil.h" -#include "DynamicLibrary.h" - -DynamicLibrary::DynamicLibrary() -{ - library = 0; -} - -// Gets the last dll error as string -const char *DllGetLastError() -{ -#ifdef _WIN32 - return GetLastErrorMsg(); -#else // not win32 - return dlerror(); -#endif // WIN32 -} - -/* Loads the dll with LoadLibrary() or dlopen. This function is called on - start to scan for plugin, and before opening the Config and Debugging - windows. It is also called from core to load the plugins when the - emulation starts. - - Returns 0 on failure and 1 on success - - TODO: think about implementing some sort of cache for the plugin info. -*/ -int DynamicLibrary::Load(const char* filename) -{ - std::string LibraryPath = File::GetPluginsDirectory() + filename; - filename = LibraryPath.c_str(); - - INFO_LOG(COMMON, "DL: Loading dynamic library %s", filename); - - if (!filename || strlen(filename) == 0) { - ERROR_LOG(COMMON, "DL: Missing filename to load"); - return 0; - } - - if (IsLoaded()) { - INFO_LOG(COMMON, "DL: library %s already loaded", filename); - return 1; - } - -#ifdef _WIN32 - library = LoadLibrary(filename); -#elif defined __linux__ - // RTLD_NOW: resolve all symbols on load - // RTLD_LOCAL: don't resolve symbols for other libraries - library = dlopen(filename, RTLD_NOW | RTLD_LOCAL); -#else - library = dlopen(NULL, RTLD_LAZY); -#endif - - DEBUG_LOG(COMMON, "DL: LoadLibrary: %s(%p)", filename, library); - - if (!library) { - ERROR_LOG(COMMON, "DL: Error loading DLL %s: %s", filename, - DllGetLastError()); - return 0; - } - - library_file = filename; - - INFO_LOG(COMMON, "DL: Done loading dynamic library %s", filename); - return 1; -} - -/* Frees one instances of the dynamic library. Note that on most systems use - reference count to decide when to actually remove the library from memory. - - Return 0 on failure and 1 on success -*/ -int DynamicLibrary::Unload() -{ - INFO_LOG(COMMON, "DL: Unloading dynamic library %s", library_file.c_str()); - int retval; - if (!IsLoaded()) { // library != null - ERROR_LOG(COMMON, "DL: Unload failed for %s: not loaded", - library_file.c_str()); - PanicAlert("DL: Unload failed %s: not loaded", - library_file.c_str()); - return 0; - } - - DEBUG_LOG(COMMON, "DL: FreeLibrary: %s %p\n", - library_file.c_str(), library); -#ifdef _WIN32 - retval = FreeLibrary(library); -#else - retval = dlclose(library) ? 0 : 1; -#endif - - if (! retval) { - ERROR_LOG(COMMON, "DL: Unload failed %s: %s", - library_file.c_str(), DllGetLastError()); - } - library = 0; - - INFO_LOG(COMMON, "DL: Done unloading dynamic library %s", - library_file.c_str()); - return retval; -} - -// Returns the address where symbol funcname is loaded or NULL on failure -void* DynamicLibrary::Get(const char* funcname) const -{ - void* retval; - - INFO_LOG(COMMON, "DL: Getting symbol %s: %s", library_file.c_str(), - funcname); - - if (!library) - { - ERROR_LOG(COMMON, "DL: Get failed %s - Library not loaded", funcname); - return NULL; - } - - #ifdef _WIN32 - retval = GetProcAddress(library, funcname); - #else - retval = dlsym(library, funcname); - #endif - - if (!retval) - { - WARN_LOG(COMMON, "DL: Symbol %s missing in %s (error: %s)\n", - funcname, library_file.c_str(), DllGetLastError()); - } - - INFO_LOG(COMMON, "DL: Done getting symbol %s: %s", library_file.c_str(), - funcname); - return retval; -} diff --git a/Source/Core/Common/Src/DynamicLibrary.h b/Source/Core/Common/Src/DynamicLibrary.h deleted file mode 100644 index b48783ce37bd..000000000000 --- a/Source/Core/Common/Src/DynamicLibrary.h +++ /dev/null @@ -1,59 +0,0 @@ -// 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 _DYNAMICLIBRARY_H_ -#define _DYNAMICLIBRARY_H_ - -#ifdef _WIN32 -#include -#endif - -#include - -/* Abstracts the (few) differences between dynamically loading DLLs under - Windows and .so / .dylib under Linux/MacOSX. */ -class DynamicLibrary -{ -public: - DynamicLibrary(); - - // Loads the library filename - int Load(const char *filename); - - // Unload the current library - int Unload(); - - // Gets a pointer to the function symbol of funcname by getting it from the - // shared object - void *Get(const char *funcname) const; - - // Returns true if the library is loaded - bool IsLoaded() const { return library != 0; } - -private: - // name of the library file - std::string library_file; - - // Library handle -#ifdef _WIN32 - HINSTANCE library; -#else - void *library; -#endif -}; - -#endif // _DYNAMICLIBRARY_H_ diff --git a/Source/Core/Common/Src/Plugin.cpp b/Source/Core/Common/Src/Plugin.cpp deleted file mode 100644 index 271b044ac34b..000000000000 --- a/Source/Core/Common/Src/Plugin.cpp +++ /dev/null @@ -1,135 +0,0 @@ -// 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/ - -// -------------------------------------------------------------------------------------------- -// This is the common Plugin class that links to the functions that are -// common to all plugins. This class is inherited by all plugin classes. But it's only created -// directly in PluginManager.cpp when we check if a plugin is valid or not. -// -------------------------------------------------------------------------------------------- - -#include "Plugin.h" - -namespace Common -{ - -CPlugin::~CPlugin() -{ - m_hInstLib.Unload(); -} - -CPlugin::CPlugin(const char* _szName) : valid(false) -{ - m_GetDllInfo = NULL; - m_DllConfig = NULL; - m_DllDebugger = NULL; - m_SetDllGlobals = NULL; - m_Initialize = NULL; - m_Shutdown = NULL; - m_DoState = NULL; - m_EmuStateChange = NULL; - - if (m_hInstLib.Load(_szName)) - { - m_GetDllInfo = reinterpret_cast - (m_hInstLib.Get("GetDllInfo")); - m_DllConfig = reinterpret_cast - (m_hInstLib.Get("DllConfig")); - m_DllDebugger = reinterpret_cast - (m_hInstLib.Get("DllDebugger")); - m_SetDllGlobals = reinterpret_cast - (m_hInstLib.Get("SetDllGlobals")); - m_Initialize = reinterpret_cast - (m_hInstLib.Get("Initialize")); - m_Shutdown = reinterpret_cast - (m_hInstLib.Get("Shutdown")); - m_DoState = reinterpret_cast - (m_hInstLib.Get("DoState")); - m_EmuStateChange = reinterpret_cast - (m_hInstLib.Get("EmuStateChange")); - - // Check if the plugin has all the functions it should have - if (m_GetDllInfo != 0 && - m_DllConfig != 0 && - m_DllDebugger != 0 && - m_SetDllGlobals != 0 && - m_Initialize != 0 && - m_Shutdown != 0 && - m_DoState != 0 && - m_EmuStateChange != 0) - valid = true; - } - - // Save the filename for this plugin - Filename = _szName; -} - -void *CPlugin::LoadSymbol(const char *sym) -{ - return m_hInstLib.Get(sym); -} - -// GetInfo: Get DLL info -bool CPlugin::GetInfo(PLUGIN_INFO& _pluginInfo) -{ - if (m_GetDllInfo != NULL) { - m_GetDllInfo(&_pluginInfo); - return true; - } - return false; -} - -// Config: Open the Config window -void CPlugin::Config(void *_hwnd) -{ - if (m_DllConfig != NULL) - m_DllConfig(_hwnd); -} - -// Debug: Open the Debugging window -void *CPlugin::Debug(void *Parent, bool Show) -{ - return m_DllDebugger(Parent, Show); -} - -void CPlugin::SetGlobals(PLUGIN_GLOBALS* _pluginGlobals) { - if (m_SetDllGlobals != NULL) - m_SetDllGlobals(_pluginGlobals); -} - -void CPlugin::DoState(unsigned char **ptr, int mode) { - if (m_DoState != NULL) - m_DoState(ptr, mode); -} - -void CPlugin::EmuStateChange(PLUGIN_EMUSTATE newState) { - if (m_EmuStateChange != NULL) - m_EmuStateChange(newState); -} - -void CPlugin::Initialize(void *init) -{ - if (m_Initialize != NULL) - m_Initialize(init); -} - -void CPlugin::Shutdown() -{ - if (m_Shutdown != NULL) - m_Shutdown(); -} - -} // Namespace diff --git a/Source/Core/Common/Src/Plugin.h b/Source/Core/Common/Src/Plugin.h deleted file mode 100644 index 2642bcdb2a8b..000000000000 --- a/Source/Core/Common/Src/Plugin.h +++ /dev/null @@ -1,75 +0,0 @@ -// 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_H_ -#define _PLUGIN_H_ - -#include "Common.h" -#include "PluginSpecs.h" -#include "DynamicLibrary.h" - -namespace Common -{ - typedef void (__cdecl * TGetDllInfo)(PLUGIN_INFO*); - typedef void (__cdecl * TDllConfig)(void *); - typedef void* (__cdecl * TDllDebugger)(void *, bool); - typedef void (__cdecl * TSetDllGlobals)(PLUGIN_GLOBALS*); - typedef void (__cdecl * TInitialize)(void *); - typedef void (__cdecl * TShutdown)(); - typedef void (__cdecl * TDoState)(unsigned char**, int); - typedef void (__cdecl * TEmuStateChange)(PLUGIN_EMUSTATE); - -class CPlugin -{ -public: - CPlugin(const char* _szName); - virtual ~CPlugin(); - - // This functions is only used when CPlugin is called directly, when a parent class like PluginVideo - // is called its own IsValid() will be called. - virtual bool IsValid() { return valid; }; - const std::string& GetFilename() const { return Filename; } - bool GetInfo(PLUGIN_INFO& _pluginInfo); - void SetGlobals(PLUGIN_GLOBALS* _PluginGlobals); - void *LoadSymbol(const char *sym); - - void Config(void *_hwnd); - void About(void *_hwnd); - void *Debug(void *Parent, bool Show); - void DoState(unsigned char **ptr, int mode); - void EmuStateChange(PLUGIN_EMUSTATE newState); - void Initialize(void *init); - void Shutdown(); - -private: - DynamicLibrary m_hInstLib; - std::string Filename; - bool valid; - - // Functions - TGetDllInfo m_GetDllInfo; - TDllConfig m_DllConfig; - TDllDebugger m_DllDebugger; - TSetDllGlobals m_SetDllGlobals; - TInitialize m_Initialize; - TShutdown m_Shutdown; - TDoState m_DoState; - TEmuStateChange m_EmuStateChange; -}; -} // Namespace - -#endif // _PLUGIN_H_ diff --git a/Source/Core/Common/Src/PluginVideo.cpp b/Source/Core/Common/Src/PluginVideo.cpp deleted file mode 100644 index a2028135fca3..000000000000 --- a/Source/Core/Common/Src/PluginVideo.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// 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 "PluginVideo.h" - -namespace Common -{ - -PluginVideo::PluginVideo(const char *_Filename) : CPlugin(_Filename), validVideo(false) -{ - Video_Prepare = 0; - Video_BeginField = 0; - Video_EndField = 0; - Video_EnterLoop = 0; - Video_ExitLoop = 0; - Video_Screenshot = 0; - Video_AddMessage = 0; - Video_AccessEFB = 0; - Video_SetRendering = 0; - Video_CommandProcessorRead16 = 0; - Video_CommandProcessorWrite16 = 0; - Video_PixelEngineRead16 = 0; - Video_PixelEngineWrite16 = 0; - Video_PixelEngineWrite32 = 0; - Video_GatherPipeBursted = 0; - Video_WaitForFrameFinish = 0; - Video_IsFifoBusy = 0; - Video_AbortFrame = 0; - - Video_Prepare = reinterpret_cast - (LoadSymbol("Video_Prepare")); - Video_BeginField = reinterpret_cast - (LoadSymbol("Video_BeginField")); - Video_EndField = reinterpret_cast - (LoadSymbol("Video_EndField")); - Video_Screenshot = reinterpret_cast - (LoadSymbol("Video_Screenshot")); - Video_EnterLoop = reinterpret_cast - (LoadSymbol("Video_EnterLoop")); - Video_ExitLoop = reinterpret_cast - (LoadSymbol("Video_ExitLoop")); - Video_AddMessage = reinterpret_cast - (LoadSymbol("Video_AddMessage")); - Video_AccessEFB = reinterpret_cast - (LoadSymbol("Video_AccessEFB")); - Video_SetRendering = reinterpret_cast - (LoadSymbol("Video_SetRendering")); - Video_CommandProcessorRead16 = reinterpret_cast - (LoadSymbol("Video_CommandProcessorRead16")); - Video_CommandProcessorWrite16 = reinterpret_cast - (LoadSymbol("Video_CommandProcessorWrite16")); - Video_PixelEngineRead16 = reinterpret_cast - (LoadSymbol("Video_PixelEngineRead16")); - Video_PixelEngineWrite16 = reinterpret_cast - (LoadSymbol("Video_PixelEngineWrite16")); - Video_PixelEngineWrite32 = reinterpret_cast - (LoadSymbol("Video_PixelEngineWrite32")); - Video_GatherPipeBursted = reinterpret_cast - (LoadSymbol("Video_GatherPipeBursted")); - Video_WaitForFrameFinish = reinterpret_cast - (LoadSymbol("Video_WaitForFrameFinish")); - Video_IsFifoBusy = reinterpret_cast - (LoadSymbol("Video_IsFifoBusy")); - Video_AbortFrame = reinterpret_cast - (LoadSymbol("Video_AbortFrame")); - if ((Video_Prepare != 0) && - (Video_BeginField != 0) && - (Video_EndField != 0) && - (Video_EnterLoop != 0) && - (Video_ExitLoop != 0) && - (Video_Screenshot != 0) && - (Video_AddMessage != 0) && - (Video_SetRendering != 0) && - (Video_AccessEFB != 0) && - (Video_SetRendering != 0) && - (Video_CommandProcessorRead16 != 0) && - (Video_CommandProcessorWrite16 != 0) && - (Video_PixelEngineRead16 != 0) && - (Video_PixelEngineWrite16 != 0) && - (Video_PixelEngineWrite32 != 0) && - (Video_GatherPipeBursted != 0) && - (Video_WaitForFrameFinish != 0) && - (Video_IsFifoBusy != 0) && - (Video_AbortFrame != 0)) - validVideo = true; -} - -PluginVideo::~PluginVideo() {} - -} // namespace diff --git a/Source/Core/Common/Src/PluginVideo.h b/Source/Core/Common/Src/PluginVideo.h deleted file mode 100644 index 0e76b2eac0ab..000000000000 --- a/Source/Core/Common/Src/PluginVideo.h +++ /dev/null @@ -1,79 +0,0 @@ -// 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 _PLUGINVIDEO_H_ -#define _PLUGINVIDEO_H_ - -#include "pluginspecs_video.h" -#include "Plugin.h" - -namespace Common { - -typedef void (__cdecl* TVideo_Prepare)(); -typedef void (__cdecl* TVideo_SendFifoData)(u8*,u32); -typedef void (__cdecl* TVideo_BeginField)(u32, FieldType, u32, u32); -typedef void (__cdecl* TVideo_EndField)(); -typedef void (__cdecl* TVideo_Screenshot)(const char* filename); -typedef void (__cdecl* TVideo_EnterLoop)(); -typedef void (__cdecl* TVideo_ExitLoop)(); -typedef void (__cdecl* TVideo_SetRendering)(bool bEnabled); -typedef void (__cdecl* TVideo_AddMessage)(const char* pstr, unsigned int milliseconds); -typedef u32 (__cdecl* TVideo_AccessEFB)(EFBAccessType, u32, u32, u32); -typedef void (__cdecl* TVideo_Read16)(u16& _rReturnValue, const u32 _Address); -typedef void (__cdecl* TVideo_Write16)(const u16 _Data, const u32 _Address); -typedef void (__cdecl* TVideo_Read32)(u32& _rReturnValue, const u32 _Address); -typedef void (__cdecl* TVideo_Write32)(const u32 _Data, const u32 _Address); -typedef void (__cdecl* TVideo_GatherPipeBursted)(); -typedef void (__cdecl* TVideo_WaitForFrameFinish)(); -typedef bool (__cdecl* TVideo_IsFifoBusy)(); -typedef void (__cdecl* TVideo_AbortFrame)(); - -class PluginVideo : public CPlugin -{ -public: - PluginVideo(const char *_Filename); - virtual ~PluginVideo(); - virtual bool IsValid() {return validVideo;}; - - TVideo_Prepare Video_Prepare; - TVideo_EnterLoop Video_EnterLoop; - TVideo_ExitLoop Video_ExitLoop; - TVideo_BeginField Video_BeginField; - TVideo_EndField Video_EndField; - TVideo_AccessEFB Video_AccessEFB; - - TVideo_AddMessage Video_AddMessage; - TVideo_Screenshot Video_Screenshot; - - TVideo_SetRendering Video_SetRendering; - - TVideo_Read16 Video_CommandProcessorRead16; - TVideo_Write16 Video_CommandProcessorWrite16; - TVideo_Read16 Video_PixelEngineRead16; - TVideo_Write16 Video_PixelEngineWrite16; - TVideo_Write32 Video_PixelEngineWrite32; - TVideo_GatherPipeBursted Video_GatherPipeBursted; - TVideo_WaitForFrameFinish Video_WaitForFrameFinish; - TVideo_IsFifoBusy Video_IsFifoBusy; - TVideo_AbortFrame Video_AbortFrame; -private: - bool validVideo; -}; - -} // namespace - -#endif // _PLUGINVIDEO_H_ diff --git a/Source/Core/Common/Src/VideoBackendBase.cpp b/Source/Core/Common/Src/VideoBackendBase.cpp new file mode 100644 index 000000000000..ff3bb809a054 --- /dev/null +++ b/Source/Core/Common/Src/VideoBackendBase.cpp @@ -0,0 +1,58 @@ +// 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 "VideoBackendBase.h" + +// TODO: ugly +#ifdef _WIN32 +#include "../Plugins/Plugin_VideoDX9/Src/VideoBackend.h" +#include "../Plugins/Plugin_VideoDX11/Src/VideoBackend.h" +#endif +#include "../Plugins/Plugin_VideoOGL/Src/VideoBackend.h" +//#include "../Plugins/Plugin_VideoSoftware/Src/VideoBackend.h" + +std::vector g_available_video_backends; +VideoBackend* g_video_backend = NULL; + +void VideoBackend::PopulateList() +{ +#ifdef _WIN32 + g_available_video_backends.push_back(new DX9::VideoBackend); + // TODO: if (winver >= VISTA) :p + g_available_video_backends.push_back(new DX11::VideoBackend); +#endif + g_available_video_backends.push_back(new OGL::VideoBackend); + //g_available_video_backends.push_back(new SW::VideoBackend); + + g_video_backend = g_available_video_backends.front(); +} + +void VideoBackend::ClearList() +{ + while (!g_available_video_backends.empty()) + { + delete g_available_video_backends.back(); + g_available_video_backends.pop_back(); + } +} + +void VideoBackend::ActivateBackend(const std::string& name) +{ + for (std::vector::const_iterator it = g_available_video_backends.begin(); it != g_available_video_backends.end(); ++it) + if (name == (*it)->GetName()) + g_video_backend = *it; +} diff --git a/Source/Core/Common/Src/VideoBackendBase.h b/Source/Core/Common/Src/VideoBackendBase.h new file mode 100644 index 000000000000..4747ec91a93b --- /dev/null +++ b/Source/Core/Common/Src/VideoBackendBase.h @@ -0,0 +1,156 @@ +// 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 VIDEO_BACKEND_H_ +#define VIDEO_BACKEND_H_ + +#include +#include + +#include "PluginSpecs.h" + +#include "ChunkFile.h" + +enum FieldType +{ + FIELD_PROGRESSIVE = 0, + FIELD_UPPER, + FIELD_LOWER +}; + +enum EFBAccessType +{ + PEEK_Z = 0, + POKE_Z, + PEEK_COLOR, + POKE_COLOR +}; + +struct SCPFifoStruct +{ + // fifo registers + volatile u32 CPBase; + volatile u32 CPEnd; + u32 CPHiWatermark; + u32 CPLoWatermark; + volatile u32 CPReadWriteDistance; + volatile u32 CPWritePointer; + volatile u32 CPReadPointer; + volatile u32 CPBreakpoint; + + // Super Monkey Ball Adventure require this. + // Because the read&check-PEToken-loop stays in its JITed block I suppose. + // So no possiblity to ack the Token irq by the scheduler until some sort of PPC watchdog do its mess. + volatile u16 PEToken; + + volatile u32 bFF_GPReadEnable; + volatile u32 bFF_BPEnable; + volatile u32 bFF_BPInt; + volatile u32 bFF_Breakpoint; + + volatile u32 CPCmdIdle; + volatile u32 CPReadIdle; + + volatile u32 bFF_LoWatermarkInt; + volatile u32 bFF_HiWatermarkInt; + + volatile u32 bFF_LoWatermark; + volatile u32 bFF_HiWatermark; + + // for GP watchdog hack + volatile u32 Fake_GPWDToken; // cicular incrementer +}; + +class VideoBackend +{ +public: + virtual ~VideoBackend() {} + + virtual void EmuStateChange(PLUGIN_EMUSTATE) = 0; + + virtual void UpdateFPSDisplay(const char*) = 0; + + virtual unsigned int PeekMessages() = 0; + + virtual void Initialize() = 0; + virtual void Shutdown() = 0; + + virtual void DoState(PointerWrap &p) = 0; + + virtual std::string GetName() = 0; + + virtual void ShowConfig(void*) {} + + virtual void Video_Prepare() = 0; + + virtual void Video_EnterLoop() = 0; + virtual void Video_ExitLoop() = 0; + + virtual void Video_BeginField(u32, FieldType, u32, u32) = 0; + virtual void Video_EndField() = 0; + + virtual u32 Video_AccessEFB(EFBAccessType, u32, u32, u32) = 0; + + virtual void Video_AddMessage(const char* pstr, unsigned int milliseconds) = 0; + virtual bool Video_Screenshot(const char* filename) = 0; + + virtual void Video_SetRendering(bool bEnabled) = 0; + + static void Video_GatherPipeBursted(); + + virtual void Video_WaitForFrameFinish() = 0; + virtual bool Video_IsFifoBusy() = 0; + virtual void Video_AbortFrame() = 0; + + static void PopulateList(); + static void ClearList(); + static void ActivateBackend(const std::string& name); +}; + +extern std::vector g_available_video_backends; +extern VideoBackend* g_video_backend; + +// inherited by dx9/dx11/ogl backends +class VideoBackendHLE : public VideoBackend +{ + void DoState(PointerWrap &p); + + void EmuStateChange(PLUGIN_EMUSTATE); + + void Video_EnterLoop(); + void Video_ExitLoop(); + void Video_BeginField(u32, FieldType, u32, u32); + void Video_EndField(); + u32 Video_AccessEFB(EFBAccessType, u32, u32, u32); + + void Video_AddMessage(const char* pstr, unsigned int milliseconds); + bool Video_Screenshot(const char* filename); + + void Video_SetRendering(bool bEnabled); + + void Video_WaitForFrameFinish(); + bool Video_IsFifoBusy(); + void Video_AbortFrame(); +}; + +// inherited by software renderer +class VideoBackendLLE : public VideoBackend +{ + +}; + +#endif diff --git a/Source/Core/Core/Core.vcproj b/Source/Core/Core/Core.vcproj index 0cf020fbc986..62b79fe3e524 100644 --- a/Source/Core/Core/Core.vcproj +++ b/Source/Core/Core/Core.vcproj @@ -1,7 +1,7 @@ - - - - diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj index 1f37d7e65d64..6916259b3985 100644 --- a/Source/Core/Core/Core.vcxproj +++ b/Source/Core/Core/Core.vcxproj @@ -127,7 +127,7 @@ Level3 Disabled - .\Src;..\Common\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\Lua;%(AdditionalIncludeDirectories) + .\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DSPCore\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\Lua;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreadedDebug stdafx.h @@ -146,7 +146,7 @@ Level3 Disabled - .\Src;..\Common\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\Lua;%(AdditionalIncludeDirectories) + .\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DSPCore\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\Lua;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreadedDebug stdafx.h @@ -167,7 +167,7 @@ MaxSpeed true true - .\Src;..\Common\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\Lua;%(AdditionalIncludeDirectories) + .\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DSPCore\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\Lua;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded false @@ -191,7 +191,7 @@ MaxSpeed true true - .\Src;..\Common\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\Lua;%(AdditionalIncludeDirectories) + .\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DSPCore\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\Lua;%(AdditionalIncludeDirectories) DEBUGFAST;_SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded false @@ -215,7 +215,7 @@ MaxSpeed true true - .\Src;..\Common\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\Lua;%(AdditionalIncludeDirectories) + .\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DSPCore\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\Lua;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded false @@ -239,7 +239,7 @@ MaxSpeed true true - .\Src;..\Common\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\Lua;%(AdditionalIncludeDirectories) + .\Src;..\Common\Src;..\VideoCommon\Src;..\AudioCommon\Src;..\DSPCore\Src;..\DiscIO\Src;..\InputCommon\Src;..\wiiuse\Src;..\..\PluginSpecs;..\..\..\Externals\Bochs_disasm;..\..\..\Externals\SFML\include;..\..\..\Externals\LZO;..\..\..\Externals\zlib;..\..\..\Externals\Lua;%(AdditionalIncludeDirectories) DEBUGFAST;_SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded false @@ -313,6 +313,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -371,7 +391,7 @@ - + @@ -481,6 +501,26 @@ + + + + + + + + + + + + + + + + + + + + @@ -543,7 +583,7 @@ - + @@ -576,20 +616,30 @@ + {cd3d4c3c-1027-4d33-b047-aec7b56d0bf6} + + {37d007bd-d66c-4eaf-b56c-bd1aac340a05} + {c87a4178-44f6-49b2-b7aa-c79af1b8c534} {b6398059-ebb6-4c34-b547-95f365b71ff4} + + {4ed3c8be-91a7-4361-8d46-16d03b678d4c} + + + {3e5c4e02-1ba9-4776-bdbe-e3f91ffa34cf} + - + \ No newline at end of file diff --git a/Source/Core/Core/Src/ConfigManager.cpp b/Source/Core/Core/Src/ConfigManager.cpp index a1a0e2c3bbd6..ce768c47776d 100644 --- a/Source/Core/Core/Src/ConfigManager.cpp +++ b/Source/Core/Core/Src/ConfigManager.cpp @@ -21,7 +21,6 @@ #include "CommonPaths.h" #include "IniFile.h" #include "ConfigManager.h" -#include "PluginManager.h" #include "FileUtil.h" SConfig* SConfig::m_Instance; @@ -184,6 +183,7 @@ void SConfig::SaveSettings() ini.Set("Core", "UseFPS", b_UseFPS); // Plugins + // TODO: change key name, it's no longer a plugin ini.Set("Core", "GFXPlugin", m_LocalCoreStartupParameter.m_strVideoPlugin); ini.Save(File::GetUserPath(F_DOLPHINCONFIG_IDX)); @@ -318,6 +318,7 @@ void SConfig::LoadSettings() ini.Get("Core", "UseFPS", &b_UseFPS, false); // use vps as default // Plugins + // TODO: change key name, it's no longer a plugin ini.Get("Core", "GFXPlugin", &m_LocalCoreStartupParameter.m_strVideoPlugin, m_DefaultGFXPlugin.c_str()); } diff --git a/Source/Core/Core/Src/Core.cpp b/Source/Core/Core/Src/Core.cpp index 7e9df77b0e28..bb03cc8e7976 100644 --- a/Source/Core/Core/Src/Core.cpp +++ b/Source/Core/Core/Src/Core.cpp @@ -54,9 +54,9 @@ #include "PowerPC/PowerPC.h" #include "PowerPC/JitCommon/JitBase.h" -#include "PluginManager.h" #include "PluginDSP.h" #include "ConfigManager.h" +#include "VideoBackendBase.h" #include "VolumeHandler.h" #include "FileMonitor.h" @@ -68,6 +68,9 @@ #include "State.h" #include "OnFrame.h" +// TODO: ugly, remove +bool g_aspect_wide; + namespace Core { @@ -77,20 +80,11 @@ volatile u32 DrawnFrame = 0; u32 DrawnVideo = 0; // Function forwarding -void Callback_VideoGetWindowSize(int& x, int& y, int& width, int& height); -void Callback_VideoRequestWindowSize(int& width, int& height); -void Callback_VideoLog(const TCHAR* _szMessage, int _bDoBreak); -void Callback_VideoCopiedToXFB(bool video_update); void Callback_DSPLog(const TCHAR* _szMessage, int _v); const char *Callback_ISOName(void); void Callback_DSPInterrupt(); void Callback_WiimoteInterruptChannel(int _number, u16 _channelID, const void* _pData, u32 _Size); -// For keyboard shortcuts. -void Callback_CoreMessage(int Id); -TPeekMessages Callback_PeekMessages = NULL; -TUpdateFPSDisplay g_pUpdateFPSDisplay = NULL; - // Function declarations void EmuThread(); @@ -131,14 +125,12 @@ bool PanicAlertToVideo(const char* text, bool yes_no) void DisplayMessage(const std::string &message, int time_in_ms) { - CPluginManager::GetInstance().GetVideo()->Video_AddMessage(message.c_str(), - time_in_ms); + g_video_backend->Video_AddMessage(message.c_str(), time_in_ms); } void DisplayMessage(const char *message, int time_in_ms) { - CPluginManager::GetInstance().GetVideo()->Video_AddMessage(message, - time_in_ms); + g_video_backend->Video_AddMessage(message, time_in_ms); } void Callback_DebuggerBreak() @@ -176,19 +168,11 @@ bool Init() return false; } - // Get a handle to the current instance of the plugin manager - CPluginManager &pManager = CPluginManager::GetInstance(); - SCoreStartupParameter &_CoreParameter = SConfig::GetInstance().m_LocalCoreStartupParameter; - - g_CoreStartupParameter = _CoreParameter; + g_CoreStartupParameter = SConfig::GetInstance().m_LocalCoreStartupParameter; // FIXME DEBUG_LOG(BOOT, dump_params()); Host_SetWaitCursor(true); - // Load all needed plugins - if (!pManager.InitPlugins()) - return false; - emuThreadGoing.Init(); // Start the emu thread @@ -207,7 +191,7 @@ void Stop() // - Hammertime! { const SCoreStartupParameter& _CoreParameter = SConfig::GetInstance().m_LocalCoreStartupParameter; g_bStopping = true; - CPluginManager::GetInstance().EmuStateChange(PLUGIN_EMUSTATE_STOP); + g_video_backend->EmuStateChange(PLUGIN_EMUSTATE_STOP); WARN_LOG(CONSOLE, "Stop [Main Thread]\t\t---- Shutting down ----"); @@ -226,7 +210,7 @@ void Stop() // - Hammertime! // concurrently with the rest of the commands in this function. We no // longer rely on Postmessage. NOTICE_LOG(CONSOLE, "%s", StopMessage(true, "Wait for Video Loop to exit ...").c_str()); - CPluginManager::GetInstance().GetVideo()->Video_ExitLoop(); + g_video_backend->Video_ExitLoop(); // Wait until the CPU finishes exiting the main run loop cpuRunloopQuit.Wait(); @@ -246,7 +230,6 @@ void Stop() // - Hammertime! void CpuThread() { - CPluginManager &Plugins = CPluginManager::GetInstance(); const SCoreStartupParameter& _CoreParameter = SConfig::GetInstance().m_LocalCoreStartupParameter; if (_CoreParameter.bCPUThread) @@ -255,7 +238,7 @@ void CpuThread() } else { - CPluginManager::GetInstance().GetVideo()->Video_Prepare(); + g_video_backend->Video_Prepare(); Common::SetCurrentThreadName("CPU-GPU thread"); } @@ -279,7 +262,7 @@ void CpuThread() // So we have to call the shutdown from the thread that started it. if (!_CoreParameter.bCPUThread) { - Plugins.ShutdownVideoPlugin(); + g_video_backend->Shutdown(); } cpuRunloopQuit.Set(); @@ -299,7 +282,6 @@ void EmuThread() Common::SetCurrentThreadName("Emuthread - starting"); const SCoreStartupParameter& _CoreParameter = SConfig::GetInstance().m_LocalCoreStartupParameter; - CPluginManager &Plugins = CPluginManager::GetInstance(); if (_CoreParameter.bLockThreads) { if (cpu_info.num_cores > 3) @@ -315,46 +297,19 @@ void EmuThread() emuThreadGoing.Set(); - // Load the VideoPlugin - SVideoInitialize VideoInitialize; - VideoInitialize.pGetMemoryPointer = Memory::GetPointer; - VideoInitialize.pSetInterrupt = ProcessorInterface::SetInterrupt; - VideoInitialize.pRegisterEvent = CoreTiming::RegisterEvent; - VideoInitialize.pScheduleEvent_Threadsafe = CoreTiming::ScheduleEvent_Threadsafe; - VideoInitialize.pRemoveEvent = CoreTiming::RemoveAllEvents; - VideoInitialize.pProcessFifoEvents = CoreTiming::ProcessFifoWaitEvents; - // This is first the m_Panel handle, then it is updated to have the new window handle - VideoInitialize.pWindowHandle = _CoreParameter.hMainWindow; - VideoInitialize.pLog = Callback_VideoLog; - VideoInitialize.pSysMessage = Host_SysMessage; - VideoInitialize.pGetWindowSize = Callback_VideoGetWindowSize; - VideoInitialize.pRequestWindowSize = Callback_VideoRequestWindowSize; - VideoInitialize.pCopiedToXFB = Callback_VideoCopiedToXFB; - VideoInitialize.pPeekMessages = NULL; - VideoInitialize.pUpdateFPSDisplay = NULL; - VideoInitialize.pMemoryBase = Memory::base; - VideoInitialize.pCoreMessage = Callback_CoreMessage; - VideoInitialize.pResetGatherPipe = GPFifo::ResetGatherPipe; - VideoInitialize.bWii = _CoreParameter.bWii; - VideoInitialize.bOnThread = _CoreParameter.bCPUThread; - VideoInitialize.Fifo_CPUBase = &ProcessorInterface::Fifo_CPUBase; - VideoInitialize.Fifo_CPUEnd = &ProcessorInterface::Fifo_CPUEnd; - VideoInitialize.Fifo_CPUWritePointer = &ProcessorInterface::Fifo_CPUWritePointer; - bool aspectWide = _CoreParameter.bWii; - if (aspectWide) + g_aspect_wide = _CoreParameter.bWii; + if (g_aspect_wide) { IniFile gameIni; gameIni.Load(_CoreParameter.m_strGameIni.c_str()); - gameIni.Get("Wii", "Widescreen", &aspectWide, !!SConfig::GetInstance().m_SYSCONF->GetData("IPL.AR")); + gameIni.Get("Wii", "Widescreen", &g_aspect_wide, !!SConfig::GetInstance().m_SYSCONF->GetData("IPL.AR")); } - VideoInitialize.bAutoAspectIs16_9 = aspectWide; - - Plugins.GetVideo()->Initialize(&VideoInitialize); // Call the dll - // Under linux, this is an X11 Window, not a HWND! - g_pWindowHandle = VideoInitialize.pWindowHandle; - Callback_PeekMessages = VideoInitialize.pPeekMessages; - g_pUpdateFPSDisplay = VideoInitialize.pUpdateFPSDisplay; + // _CoreParameter.hMainWindow is first the m_Panel handle, then it is updated to have the new window handle, + // within g_video_backend->Initialize() + // TODO: that's ugly, change Initialize() to take m_Panel and return the new window handle + g_video_backend->Initialize(); + g_pWindowHandle = _CoreParameter.hMainWindow; DSP::GetPlugin()->Initialize(g_pWindowHandle, _CoreParameter.bWii, _CoreParameter.bDSPThread); @@ -395,7 +350,7 @@ void EmuThread() // This thread, after creating the EmuWindow, spawns a CPU thread, // and then takes over and becomes the video thread - Plugins.GetVideo()->Video_Prepare(); // wglMakeCurrent + g_video_backend->Video_Prepare(); // wglMakeCurrent cpuThread = std::thread(CpuThread); Common::SetCurrentThreadName("Video thread"); @@ -403,7 +358,7 @@ void EmuThread() Host_UpdateDisasmDialog(); Host_UpdateMainFrame(); - Plugins.GetVideo()->Video_EnterLoop(); + g_video_backend->Video_EnterLoop(); } else // SingleCore mode { @@ -423,8 +378,7 @@ void EmuThread() // then we lose the powerdown check. ... unless powerdown sends a message :P while (PowerPC::GetState() != PowerPC::CPU_POWERDOWN) { - if (Callback_PeekMessages) - Callback_PeekMessages(); + g_video_backend->PeekMessages(); Common::SleepCurrentThread(20); } @@ -465,7 +419,7 @@ void EmuThread() WARN_LOG(CONSOLE, "%s", StopMessage(false, "Shutting down plugins").c_str()); // In single core mode, this has already been called. if (_CoreParameter.bCPUThread) - Plugins.ShutdownVideoPlugin(); + g_video_backend->Shutdown(); Pad::Shutdown(); Wiimote::Shutdown(); @@ -540,7 +494,7 @@ void ScreenShot(const std::string& name) bool bPaused = (GetState() == CORE_PAUSE); SetState(CORE_PAUSE); - CPluginManager::GetInstance().GetVideo()->Video_Screenshot(name.c_str()); + g_video_backend->Video_Screenshot(name.c_str()); if(!bPaused) SetState(CORE_RUN); } @@ -621,8 +575,7 @@ void VideoThrottle() SMessage; // Show message - if (g_pUpdateFPSDisplay != NULL) - g_pUpdateFPSDisplay(SMessage.c_str()); + g_video_backend->UpdateFPSDisplay(SMessage.c_str()); if (_CoreParameter.bRenderToMain && SConfig::GetInstance().m_InterfaceStatusbar) { @@ -658,7 +611,7 @@ bool report_slow(int skipped) // Callback_VideoLog // WARNING - THIS IS EXECUTED FROM VIDEO THREAD -void Callback_VideoLog(const TCHAR *_szMessage, int _bDoBreak) +void Callback_VideoLog(const char *_szMessage, int _bDoBreak) { INFO_LOG(VIDEO, "%s", _szMessage); } diff --git a/Source/Core/Core/Src/Core.h b/Source/Core/Core/Src/Core.h index ec3cc9d5d29f..b9368754aaf4 100644 --- a/Source/Core/Core/Src/Core.h +++ b/Source/Core/Core/Src/Core.h @@ -33,6 +33,13 @@ namespace Core { + +void Callback_VideoLog(const char* _szMessage, int _bDoBreak); +void Callback_VideoCopiedToXFB(bool video_update); +void Callback_VideoGetWindowSize(int& x, int& y, int& width, int& height); +void Callback_VideoRequestWindowSize(int& width, int& height); +void Callback_CoreMessage(int Id); + enum EState { CORE_UNINITIALIZED, diff --git a/Source/Core/Core/Src/CoreTiming.cpp b/Source/Core/Core/Src/CoreTiming.cpp index a102f3ef84d5..6bf967ff1efb 100644 --- a/Source/Core/Core/Src/CoreTiming.cpp +++ b/Source/Core/Core/Src/CoreTiming.cpp @@ -22,7 +22,7 @@ #include "CoreTiming.h" #include "Core.h" #include "StringUtil.h" -#include "PluginManager.h" +#include "VideoBackendBase.h" #define MAX_SLICE_LENGTH 20000 @@ -520,7 +520,7 @@ void Idle() //When the FIFO is processing data we must not advance because in this way //the VI will be desynchronized. So, We are waiting until the FIFO finish and //while we process only the events required by the FIFO. - while (CPluginManager::GetInstance().GetVideo()->Video_IsFifoBusy()) + while (g_video_backend->Video_IsFifoBusy()) { ProcessFifoWaitEvents(); Common::YieldCPU(); diff --git a/Source/Core/Core/Src/HW/CPU.cpp b/Source/Core/Core/Src/HW/CPU.cpp index c1f2312c1fa1..e5649b16a7f3 100644 --- a/Source/Core/Core/Src/HW/CPU.cpp +++ b/Source/Core/Core/Src/HW/CPU.cpp @@ -18,13 +18,12 @@ #include "Common.h" #include "Thread.h" -#include "../PluginDSP.h" -#include "../PluginManager.h" #include "../PowerPC/PowerPC.h" #include "../Host.h" #include "../Core.h" #include "CPU.h" -#include "DSP.h" + +#include "VideoBackendBase.h" namespace { @@ -116,15 +115,13 @@ void CCPU::EnableStepping(const bool _bStepping) if (_bStepping) { PowerPC::Pause(); - CPluginManager::GetInstance().EmuStateChange(PLUGIN_EMUSTATE_PAUSE); - DSP::GetPlugin()->DSP_ClearAudioBuffer(true); + g_video_backend->EmuStateChange(PLUGIN_EMUSTATE_PAUSE); } else { PowerPC::Start(); m_StepEvent.Set(); - CPluginManager::GetInstance().EmuStateChange(PLUGIN_EMUSTATE_PLAY); - DSP::GetPlugin()->DSP_ClearAudioBuffer(false); + g_video_backend->EmuStateChange(PLUGIN_EMUSTATE_PLAY); } } diff --git a/Source/Core/Core/Src/HW/DSP.cpp b/Source/Core/Core/Src/HW/DSP.cpp index 9b16464d62d9..e67285287413 100644 --- a/Source/Core/Core/Src/HW/DSP.cpp +++ b/Source/Core/Core/Src/HW/DSP.cpp @@ -45,7 +45,6 @@ #include "ProcessorInterface.h" #include "AudioInterface.h" #include "../PowerPC/PowerPC.h" -#include "../PluginManager.h" #include "../ConfigManager.h" #include "../PluginDSP.h" diff --git a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.h b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.h index c41cf951e2f3..de13a3f35696 100644 --- a/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.h +++ b/Source/Core/Core/Src/HW/DSPLLE/DSPLLE.h @@ -29,6 +29,7 @@ class DSPLLE : public PluginDSP { virtual void Initialize(void *hWnd, bool bWii, bool bDSPThread); virtual void Shutdown(); + virtual bool IsLLE() { return true; } virtual void DoState(PointerWrap &p); diff --git a/Source/Core/Core/Src/HW/GPFifo.cpp b/Source/Core/Core/Src/HW/GPFifo.cpp index 4021e5bee333..79690e5f07e7 100644 --- a/Source/Core/Core/Src/HW/GPFifo.cpp +++ b/Source/Core/Core/Src/HW/GPFifo.cpp @@ -18,10 +18,11 @@ #include "Common.h" #include "ChunkFile.h" #include "ProcessorInterface.h" -#include "../PluginManager.h" #include "Memmap.h" #include "../PowerPC/PowerPC.h" +#include "VideoBackendBase.h" + #include "GPFifo.h" namespace GPFifo @@ -42,9 +43,7 @@ namespace GPFifo u8 GC_ALIGNED32(m_gatherPipe[GATHER_PIPE_SIZE*16]); //more room, for the fastmodes // pipe counter -u32 m_gatherPipeCount = 0; - -Common::TVideo_GatherPipeBursted m_GatherPipeBursted = NULL; +u32 m_gatherPipeCount = 0; void DoState(PointerWrap &p) { @@ -55,7 +54,6 @@ void DoState(PointerWrap &p) void Init() { ResetGatherPipe(); - m_GatherPipeBursted = CPluginManager::GetInstance().GetVideo()->Video_GatherPipeBursted; } bool IsEmpty() @@ -92,8 +90,7 @@ void STACKALIGN CheckGatherPipe() ProcessorInterface::Fifo_CPUWritePointer += GATHER_PIPE_SIZE; } - // Call pre-fetched pointer - m_GatherPipeBursted(); + g_video_backend->Video_GatherPipeBursted(); } // move back the spill bytes diff --git a/Source/Core/Core/Src/HW/HW.cpp b/Source/Core/Core/Src/HW/HW.cpp index 40006d3f3bc5..51ae87a34138 100644 --- a/Source/Core/Core/Src/HW/HW.cpp +++ b/Source/Core/Core/Src/HW/HW.cpp @@ -31,7 +31,6 @@ #include "AudioInterface.h" #include "VideoInterface.h" #include "WII_IPC.h" -#include "../PluginManager.h" #include "../ConfigManager.h" #include "../CoreTiming.h" #include "SystemTimers.h" diff --git a/Source/Core/Core/Src/HW/Memmap.cpp b/Source/Core/Core/Src/HW/Memmap.cpp index 0fd9c9c77ecb..b99884784a98 100644 --- a/Source/Core/Core/Src/HW/Memmap.cpp +++ b/Source/Core/Core/Src/HW/Memmap.cpp @@ -39,14 +39,14 @@ may be redirected here (for example to Read_U32()). #include "VideoInterface.h" #include "SI.h" #include "EXI.h" -#include "PluginVideo.h" #include "AudioInterface.h" #include "MemoryInterface.h" #include "WII_IOB.h" #include "WII_IPC.h" #include "../ConfigManager.h" #include "../Debugger/Debugger_SymbolMap.h" -#include "../PluginManager.h" +#include "CommandProcessor.h" +#include "PixelEngine.h" namespace Memory { @@ -180,12 +180,12 @@ void InitHWMemFuncs() for (int i = 0; i < BLOCKSIZE; i++) { - hwRead16 [CP_START+i] = CPluginManager::GetInstance().GetVideo()->Video_CommandProcessorRead16; - hwWrite16[CP_START+i] = CPluginManager::GetInstance().GetVideo()->Video_CommandProcessorWrite16; + hwRead16 [CP_START+i] = CommandProcessor::Read16; + hwWrite16[CP_START+i] = CommandProcessor::Write16; - hwRead16 [PE_START+i] = CPluginManager::GetInstance().GetVideo()->Video_PixelEngineRead16; - hwWrite16[PE_START+i] = CPluginManager::GetInstance().GetVideo()->Video_PixelEngineWrite16; - hwWrite32[PE_START+i] = CPluginManager::GetInstance().GetVideo()->Video_PixelEngineWrite32; + hwRead16 [PE_START+i] = PixelEngine::Read16; + hwWrite16[PE_START+i] = PixelEngine::Write16; + hwWrite32[PE_START+i] = PixelEngine::Write32; hwRead8 [VI_START+i] = VideoInterface::Read8; hwRead16 [VI_START+i] = VideoInterface::Read16; @@ -253,12 +253,12 @@ void InitHWMemFuncsWii() // MI, PI, DSP are still mapped to 0xCCxxxxxx for (int i = 0; i < BLOCKSIZE; i++) { - hwRead16 [CP_START+i] = CPluginManager::GetInstance().GetVideo()->Video_CommandProcessorRead16; - hwWrite16[CP_START+i] = CPluginManager::GetInstance().GetVideo()->Video_CommandProcessorWrite16; + hwRead16 [CP_START+i] = CommandProcessor::Read16; + hwWrite16[CP_START+i] = CommandProcessor::Write16; - hwRead16 [PE_START+i] = CPluginManager::GetInstance().GetVideo()->Video_PixelEngineRead16; - hwWrite16[PE_START+i] = CPluginManager::GetInstance().GetVideo()->Video_PixelEngineWrite16; - hwWrite32[PE_START+i] = CPluginManager::GetInstance().GetVideo()->Video_PixelEngineWrite32; + hwRead16 [PE_START+i] = PixelEngine::Read16; + hwWrite16[PE_START+i] = PixelEngine::Write16; + hwWrite32[PE_START+i] = PixelEngine::Write32; hwRead16 [PI_START+i] = ProcessorInterface::Read16; hwRead32 [PI_START+i] = ProcessorInterface::Read32; diff --git a/Source/Core/Core/Src/HW/MemmapFunctions.cpp b/Source/Core/Core/Src/HW/MemmapFunctions.cpp index 8c5a025cc587..c79658f2c2c7 100644 --- a/Source/Core/Core/Src/HW/MemmapFunctions.cpp +++ b/Source/Core/Core/Src/HW/MemmapFunctions.cpp @@ -23,7 +23,7 @@ #include "WII_IOB.h" #include "../Core.h" #include "../PowerPC/PowerPC.h" -#include "../PluginManager.h" +#include "VideoBackendBase.h" namespace Memory { @@ -133,10 +133,10 @@ u32 EFB_Read(const u32 addr) int y = (addr >> 12) & 0x3ff; if (addr & 0x00400000) { - var = CPluginManager::GetInstance().GetVideo()->Video_AccessEFB(PEEK_Z, x, y, 0); + var = g_video_backend->Video_AccessEFB(PEEK_Z, x, y, 0); DEBUG_LOG(MEMMAP, "EFB Z Read @ %i, %i\t= 0x%08x", x, y, var); } else { - var = CPluginManager::GetInstance().GetVideo()->Video_AccessEFB(PEEK_COLOR, x, y, 0); + var = g_video_backend->Video_AccessEFB(PEEK_COLOR, x, y, 0); DEBUG_LOG(MEMMAP, "EFB Color Read @ %i, %i\t= 0x%08x", x, y, var); } @@ -229,10 +229,10 @@ inline void WriteToHardware(u32 em_address, const T data, u32 effective_address, int y = (em_address >> 12) & 0x3ff; // TODO figure out a way to send data without falling into the template trap if (em_address & 0x00400000) { - CPluginManager::GetInstance().GetVideo()->Video_AccessEFB(POKE_Z, x, y, (u32)data); + g_video_backend->Video_AccessEFB(POKE_Z, x, y, (u32)data); DEBUG_LOG(MEMMAP, "EFB Z Write %08x @ %i, %i", (u32)data, x, y); } else { - CPluginManager::GetInstance().GetVideo()->Video_AccessEFB(POKE_COLOR, x, y,(u32)data); + g_video_backend->Video_AccessEFB(POKE_COLOR, x, y,(u32)data); DEBUG_LOG(MEMMAP, "EFB Color Write %08x @ %i, %i", (u32)data, x, y); } return; diff --git a/Source/Core/Core/Src/HW/ProcessorInterface.cpp b/Source/Core/Core/Src/HW/ProcessorInterface.cpp index 4957a1e59fb9..4653afb43e56 100644 --- a/Source/Core/Core/Src/HW/ProcessorInterface.cpp +++ b/Source/Core/Core/Src/HW/ProcessorInterface.cpp @@ -25,7 +25,8 @@ #include "../CoreTiming.h" #include "ProcessorInterface.h" #include "GPFifo.h" -#include "../PluginManager.h" +#include "VideoBackendBase.h" + namespace ProcessorInterface { @@ -190,7 +191,7 @@ void Write32(const u32 _uValue, const u32 _iAddress) case PI_FIFO_RESET: //Abort the actual frame - CPluginManager::GetInstance().GetVideo()->Video_AbortFrame(); + g_video_backend->Video_AbortFrame(); //Fifo_CPUWritePointer = Fifo_CPUBase; ?? //PanicAlert("Unknown write to PI_FIFO_RESET (%08x)", _uValue); WARN_LOG(PROCESSORINTERFACE, "Fifo reset (%08x)", _uValue); diff --git a/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp b/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp index e17dcdc897c0..b22412764d06 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp +++ b/Source/Core/Core/Src/HW/SI_DeviceAMBaseboard.cpp @@ -23,8 +23,6 @@ #include "GCPadStatus.h" #include "GCPad.h" -#include "../PluginManager.h" // for pad state - // where to put baseboard debug #define AMBASEBOARDDEBUG OSREPORT diff --git a/Source/Core/Core/Src/HW/SI_DeviceGCController.h b/Source/Core/Core/Src/HW/SI_DeviceGCController.h index 554091b9ca06..257f7b8104dc 100644 --- a/Source/Core/Core/Src/HW/SI_DeviceGCController.h +++ b/Source/Core/Core/Src/HW/SI_DeviceGCController.h @@ -18,7 +18,6 @@ #ifndef _SI_DEVICEGCCONTROLLER_H #define _SI_DEVICEGCCONTROLLER_H -#include "../PluginManager.h" #include "SI_Device.h" #include "GCPadStatus.h" diff --git a/Source/Core/Core/Src/HW/SystemTimers.cpp b/Source/Core/Core/Src/HW/SystemTimers.cpp index 52cdc5078cb1..35817b3895f2 100644 --- a/Source/Core/Core/Src/HW/SystemTimers.cpp +++ b/Source/Core/Core/Src/HW/SystemTimers.cpp @@ -61,7 +61,6 @@ IPC_HLE_PERIOD: For the Wiimote this is the call schedule: #include "Atomic.h" #include "../PatchEngine.h" #include "SystemTimers.h" -#include "../PluginManager.h" #include "../HW/DSP.h" #include "../HW/AudioInterface.h" #include "../HW/VideoInterface.h" @@ -74,7 +73,7 @@ IPC_HLE_PERIOD: For the Wiimote this is the call schedule: #include "../PluginDSP.h" #include "Thread.h" #include "Timer.h" - +#include "VideoBackendBase.h" namespace SystemTimers @@ -228,7 +227,7 @@ u64 GetFakeTimeBase() // For DC watchdog hack void FakeGPWatchdogCallback(u64 userdata, int cyclesLate) { - CPluginManager::GetInstance().GetVideo()->Video_WaitForFrameFinish(); // lock CPUThread until frame finish + g_video_backend->Video_WaitForFrameFinish(); // lock CPUThread until frame finish CoreTiming::ScheduleEvent(VideoInterface::GetTicksPerFrame() - cyclesLate, et_FakeGPWD); } diff --git a/Source/Core/Core/Src/HW/VideoInterface.cpp b/Source/Core/Core/Src/HW/VideoInterface.cpp index 36ed817849db..c1d0c2607f78 100644 --- a/Source/Core/Core/Src/HW/VideoInterface.cpp +++ b/Source/Core/Core/Src/HW/VideoInterface.cpp @@ -23,11 +23,12 @@ #include "ProcessorInterface.h" #include "VideoInterface.h" #include "Memmap.h" -#include "../PluginManager.h" #include "../CoreTiming.h" #include "../HW/SystemTimers.h" #include "StringUtil.h" +#include "VideoBackendBase.h" + namespace VideoInterface { @@ -783,19 +784,14 @@ static void BeginField(FieldType field) fieldTypeNames[field] ); - Common::PluginVideo* video = CPluginManager::GetInstance().GetVideo(); - if (xfbAddr && video->IsValid()) - video->Video_BeginField(xfbAddr, field, fbWidth, fbHeight); + if (xfbAddr) + g_video_backend->Video_BeginField(xfbAddr, field, fbWidth, fbHeight); } static void EndField() { - Common::PluginVideo* video = CPluginManager::GetInstance().GetVideo(); - if (video->IsValid()) - { - video->Video_EndField(); - Core::VideoThrottle(); - } + g_video_backend->Video_EndField(); + Core::VideoThrottle(); } // Purpose: Send VI interrupt when triggered diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp index b7d8cda37f7a..22fdbcdb4ad3 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.cpp @@ -20,7 +20,6 @@ #include "WII_IPC_HLE_WiiMote.h" // Core #include "WII_IPC_HLE_Device_usb.h" -#include "../PluginManager.h" #include "../ConfigManager.h" #include "../Host.h" #include "../Core.h" diff --git a/Source/Core/Core/Src/LuaInterface.cpp b/Source/Core/Core/Src/LuaInterface.cpp index 05054ee6692d..f0b4b30475ac 100644 --- a/Source/Core/Core/Src/LuaInterface.cpp +++ b/Source/Core/Core/Src/LuaInterface.cpp @@ -27,13 +27,13 @@ #include "Core.h" #include "State.h" #include "ConfigManager.h" -#include "PluginManager.h" #include "HW/DSP.h" #include "HW/Memmap.h" #include "Host.h" #include "PowerPC/PowerPC.h" #include "CoreTiming.h" #include "PluginDSP.h" +#include "VideoBackendBase.h" extern "C" { #include "lua.h" @@ -1375,14 +1375,14 @@ DEFINE_LUA_FUNCTION(emulua_frameadvance, "") // run 1 frame if(info.speedMode == SPEEDMODE_MAXIMUM) - CPluginManager::GetInstance().GetVideo()->Video_SetRendering(false); + g_video_backend->Video_SetRendering(false); if(Core::GetState() == Core::CORE_PAUSE) Core::SetState(Core::CORE_RUN); PowerPC::RunLoop(); // continue as normal if(info.speedMode == SPEEDMODE_MAXIMUM) - CPluginManager::GetInstance().GetVideo()->Video_SetRendering(true); + g_video_backend->Video_SetRendering(true); Frame::SetFrameStopping(false); *PowerPC::GetStatePtr() = PowerPC::CPU_RUNNING; diff --git a/Source/Core/Core/Src/OnFrame.cpp b/Source/Core/Core/Src/OnFrame.cpp index 1576fb61da5a..db1454511940 100644 --- a/Source/Core/Core/Src/OnFrame.cpp +++ b/Source/Core/Core/Src/OnFrame.cpp @@ -18,11 +18,11 @@ #include "OnFrame.h" #include "Core.h" -#include "PluginManager.h" #include "Thread.h" #include "FileUtil.h" #include "PowerPC/PowerPC.h" #include "HW/SI.h" +#include "VideoBackendBase.h" Common::CriticalSection cs_frameSkip; @@ -77,7 +77,7 @@ void SetFrameSkipping(unsigned int framesToSkip) // Don't forget to re-enable rendering in case it wasn't... // as this won't be changed anymore when frameskip is turned off if (framesToSkip == 0) - CPluginManager::GetInstance().GetVideo()->Video_SetRendering(true); + g_video_backend->Video_SetRendering(true); cs_frameSkip.Leave(); } @@ -110,7 +110,7 @@ void FrameSkipping() if (g_frameSkipCounter > g_framesToSkip || Core::report_slow(g_frameSkipCounter) == false) g_frameSkipCounter = 0; - CPluginManager::GetInstance().GetVideo()->Video_SetRendering(!g_frameSkipCounter); + g_video_backend->Video_SetRendering(!g_frameSkipCounter); cs_frameSkip.Leave(); } diff --git a/Source/Core/Core/Src/PluginDSP.h b/Source/Core/Core/Src/PluginDSP.h index 45975f083160..0d71bdb61387 100644 --- a/Source/Core/Core/Src/PluginDSP.h +++ b/Source/Core/Core/Src/PluginDSP.h @@ -19,6 +19,7 @@ #define _PLUGINDSP_H_ +#include "PluginSpecs.h" // TODO: Only here for EmuStateChange #include "ChunkFile.h" class PluginDSP diff --git a/Source/Core/Core/Src/PluginManager.cpp b/Source/Core/Core/Src/PluginManager.cpp deleted file mode 100644 index fdeb46535a51..000000000000 --- a/Source/Core/Core/Src/PluginManager.cpp +++ /dev/null @@ -1,295 +0,0 @@ -// 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/ - -// File description -/* ------------ - This file controls when plugins are loaded and unloaded from memory. Its functions scan for valid - plugins when Dolphin is booted, and open the debugging and config windows. The PluginManager is - created once when Dolphin starts and is closed when Dolphin is closed. -*/ - -// Include -// ------------ -#include // System -#include - -#include "Common.h" -#include "CommonPaths.h" -#include "PluginManager.h" -#include "ConfigManager.h" -#include "LogManager.h" -#include "Core.h" -#include "Host.h" - -#include "FileSearch.h" // Common -#include "FileUtil.h" -#include "StringUtil.h" -#include "MemoryUtil.h" -#include "Setup.h" - -// Create the plugin manager class -CPluginManager* CPluginManager::m_Instance; - -// The Plugin Manager Class -// ------------ - -void CPluginManager::Init() -{ - m_Instance = new CPluginManager; -} - -void CPluginManager::Shutdown() -{ - delete m_Instance; - m_Instance = NULL; -} - -// The plugin manager is some sort of singleton that runs during Dolphin's entire lifespan. -CPluginManager::CPluginManager() -{ - m_PluginGlobals = new PLUGIN_GLOBALS; - - // Start LogManager - m_PluginGlobals->logManager = LogManager::GetInstance(); - - m_params = &(SConfig::GetInstance().m_LocalCoreStartupParameter); - - // Set initial values to NULL. - m_video = NULL; -} - -// This will call FreeLibrary() for all plugins -CPluginManager::~CPluginManager() -{ - INFO_LOG(CONSOLE, "Delete CPluginManager\n"); - - delete m_PluginGlobals; - delete m_video; -} - - -// Init and Shutdown Plugins -// ------------ -// Function: Point the m_pad[] and other variables to a certain plugin -bool CPluginManager::InitPlugins() -{ - // Update pluginglobals. - if (SConfig::GetInstance().m_LocalCoreStartupParameter.m_strGameIni.size() == 0) - { - PanicAlertT("Bad gameini filename"); - } - strcpy(m_PluginGlobals->game_ini, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strGameIni.c_str()); - strcpy(m_PluginGlobals->unique_id, SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID().c_str()); - INFO_LOG(CONSOLE, "Before GetVideo\n"); - - if (!GetVideo()) { - PanicAlertT("Can't init Video Plugin"); - return false; - } - INFO_LOG(CONSOLE, "After GetVideo\n"); - - return true; -} - -void CPluginManager::ShutdownVideoPlugin() -{ - if (m_video) - { - m_video->Shutdown(); - FreeVideo(); - NOTICE_LOG(CONSOLE, "%s", Core::StopMessage(false, "Video shutdown").c_str()); - } -} - - - -// The PluginInfo class: Find Valid Plugins -// ------------ -/* Function: This info is used in ScanForPlugins() to check for valid plugins and and in LoadPlugin() to - check that the filename we want to use is a good DLL. */ -CPluginInfo::CPluginInfo(const char *_rFilename) - : m_Filename(_rFilename) - , m_Valid(false) -{ - // Check if the functions that are common to all plugins are present - Common::CPlugin *plugin = new Common::CPlugin(_rFilename); - if (plugin->IsValid()) - { - if (plugin->GetInfo(m_PluginInfo)) - m_Valid = true; - else - PanicAlertT("Could not get info about plugin %s", _rFilename); - // We are now done with this plugin and will call FreeLibrary() - delete plugin; - } - else - { - WARN_LOG(CONSOLE, "PluginInfo: %s is not a valid Dolphin plugin. Ignoring.", _rFilename); - } -} - - - - -// Supporting functions -// ------------ - -/* Return the plugin info we saved when Dolphin was started. We don't even add a function to try load a - plugin name that was not found because in that case it must have been deleted while Dolphin was running. - If the user has done that he will instead get the "Can't open %s, it's missing" message. */ -void CPluginManager::GetPluginInfo(CPluginInfo *&info, std::string Filename) -{ - for (int i = 0; i < (int)m_PluginInfos.size(); i++) - { - if (m_PluginInfos.at(i).GetFilename() == Filename) - { - info = &m_PluginInfos.at(i); - return; - } - } -} - -/* Called from: Get__() functions in this file only (not from anywhere else), - therefore we can leave all condition checks in the Get__() functions - below. */ -void *CPluginManager::LoadPlugin(const char *_rFilename) -{ - Common::CPlugin *plugin = new Common::PluginVideo(_rFilename); - - // Check that the plugin has all the common and all the type specific functions - if (!plugin->IsValid()) - { - PanicAlertT("Can't open %s, it has a missing function", _rFilename); - delete plugin; - return NULL; - } - - // Call the DLL function SetGlobals - plugin->SetGlobals(m_PluginGlobals); - return plugin; -} - -PLUGIN_GLOBALS* CPluginManager::GetGlobals() -{ - return m_PluginGlobals; -} - -// ---------------------------------------- -// Create list of available plugins -// ------------- -void CPluginManager::ScanForPlugins() -{ - m_PluginInfos.clear(); - // Get plugins dir - CFileSearch::XStringVector Directories; - - Directories.push_back(File::GetPluginsDirectory()); - - CFileSearch::XStringVector Extensions; - Extensions.push_back("*" PLUGIN_SUFFIX); - // Get all DLL files in the plugins dir - CFileSearch FileSearch(Extensions, Directories); - const CFileSearch::XStringVector& rFilenames = FileSearch.GetFileNames(); - - if (rFilenames.size() > 0) - { - for (size_t i = 0; i < rFilenames.size(); i++) - { - std::string orig_name = rFilenames[i]; - std::string Filename, Extension; - - if (!SplitPath(rFilenames[i], NULL, &Filename, &Extension)) { - printf("Bad Path %s\n", rFilenames[i].c_str()); - return; - } - - // Leave off the directory component - std::string StoredName = Filename; - StoredName += Extension; - - CPluginInfo PluginInfo(StoredName.c_str()); - if (PluginInfo.IsValid()) - { - // Save the Plugin - m_PluginInfos.push_back(PluginInfo); - } - } - } -} - -Common::PluginVideo *CPluginManager::GetVideo() -{ - /* We don't need to check if m_video->IsValid() here, because m_video will not be set by LoadPlugin() - if it's not valid */ - if (m_video != NULL) - { - return m_video; - } - - // and load a new plugin - m_video = (Common::PluginVideo*)LoadPlugin(m_params->m_strVideoPlugin.c_str()); - return m_video; -} - -// Free plugins to completely reset all variables and potential DLLs loaded by -// the plugins in turn -void CPluginManager::FreeVideo() -{ - WARN_LOG(CONSOLE, "%s", Core::StopMessage(false, "Will unload video DLL").c_str()); - delete m_video; - m_video = NULL; -} - -void CPluginManager::EmuStateChange(PLUGIN_EMUSTATE newState) -{ - GetVideo()->EmuStateChange(newState); -} - -// Call DLL functions -// ------------ - -// Open config window. Input: _rFilename = Plugin filename , Type = Plugin type -void CPluginManager::OpenConfig(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type) -{ - switch(Type) - { - case PLUGIN_TYPE_VIDEO: - if (GetVideo() != NULL) - GetVideo()->Config(_Parent); - break; - - default: - PanicAlertT("Type %d config not supported in plugin %s", Type, _rFilename); - break; - } -} - -// Open debugging window. Type = Video or DSP. Show = Show or hide window. -void *CPluginManager::OpenDebug(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type, bool Show) -{ - switch(Type) - { - case PLUGIN_TYPE_VIDEO: - return GetVideo()->Debug(_Parent, Show); - break; - - default: - PanicAlert("Type %d debug not supported in plugin %s", Type, _rFilename); - return NULL; - break; - } -} diff --git a/Source/Core/Core/Src/PluginManager.h b/Source/Core/Core/Src/PluginManager.h deleted file mode 100644 index 3aab27fe7067..000000000000 --- a/Source/Core/Core/Src/PluginManager.h +++ /dev/null @@ -1,79 +0,0 @@ -// 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_MANAGER_H_ -#define __PLUGIN_MANAGER_H_ - -#include "Plugin.h" -#include "PluginVideo.h" -#include "CoreParameter.h" - -class CPluginInfo -{ -public: - CPluginInfo(const char *_rFileName); - bool IsValid() const {return(m_Valid);} - const PLUGIN_INFO& GetPluginInfo() const {return(m_PluginInfo);} - const std::string& GetFilename() const {return(m_Filename);} - -private: - PLUGIN_INFO m_PluginInfo; - std::string m_Filename; - bool m_Valid; -}; - -typedef std::vectorCPluginInfos; - - -class CPluginManager : NonCopyable -{ -public: - static CPluginManager& GetInstance() {return(*m_Instance);} - - static void Init(); - static void Shutdown(); - - Common::PluginVideo *GetVideo(); - - void FreeVideo(); - - void EmuStateChange(PLUGIN_EMUSTATE newState); - - bool InitPlugins(); - void ShutdownVideoPlugin(); - void ScanForPlugins(); - void OpenConfig(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type); - void *OpenDebug(void* _Parent, const char *_rFilename, PLUGIN_TYPE Type, bool Show); - const CPluginInfos& GetPluginInfos() {return(m_PluginInfos);} - PLUGIN_GLOBALS* GetGlobals(); - -private: - static CPluginManager* m_Instance; - - CPluginInfos m_PluginInfos; - PLUGIN_GLOBALS *m_PluginGlobals; - Common::PluginVideo *m_video; - - SCoreStartupParameter * m_params; - CPluginManager(); - ~CPluginManager(); - void GetPluginInfo(CPluginInfo *&info, std::string Filename); - void *LoadPlugin(const char *_rFilename); -}; - - -#endif diff --git a/Source/Core/Core/Src/State.cpp b/Source/Core/Core/Src/State.cpp index df639300196b..3602c83c2c9f 100644 --- a/Source/Core/Core/Src/State.cpp +++ b/Source/Core/Core/Src/State.cpp @@ -30,7 +30,7 @@ #include "HW/CPU.h" #include "PowerPC/JitCommon/JitBase.h" -#include "PluginManager.h" +#include "VideoBackendBase.h" #include @@ -88,8 +88,7 @@ void DoState(PointerWrap &p) return; } // Begin with video plugin, so that it gets a chance to clear it's caches and writeback modified things to RAM - CPluginManager &pm = CPluginManager::GetInstance(); - pm.GetVideo()->DoState(p.GetPPtr(), p.GetMode()); + g_video_backend->DoState(p); if (Core::g_CoreStartupParameter.bWii) Wiimote::DoState(p.GetPPtr(), p.GetMode()); diff --git a/Source/Core/DebuggerWX/Src/CodeWindow.cpp b/Source/Core/DebuggerWX/Src/CodeWindow.cpp index f312e840faf5..ad600222ae60 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindow.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindow.cpp @@ -55,7 +55,6 @@ #include "PowerPC/JitCommon/JitBase.h" #include "PowerPC/JitCommon/JitCache.h" // for ClearCache() -#include "PluginManager.h" #include "ConfigManager.h" extern "C" // Bitmaps diff --git a/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp b/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp index ea4b7dd75880..1913e72f5651 100644 --- a/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp +++ b/Source/Core/DebuggerWX/Src/CodeWindowFunctions.cpp @@ -58,7 +58,6 @@ #include "PowerPC/JitCommon/JitBase.h" #include "PowerPC/JitCommon/JitCache.h" // for ClearCache() -#include "PluginManager.h" #include "ConfigManager.h" extern "C" // Bitmaps @@ -542,15 +541,11 @@ void CCodeWindow::ToggleSoundWindow(bool bShow) void CCodeWindow::ToggleDLLWindow(int Id, bool bShow) { std::string DLLName; - int PluginType; + //int PluginType; wxPanel *Win; switch(Id) { - case IDM_VIDEOWINDOW: - DLLName = SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str(); - PluginType = PLUGIN_TYPE_VIDEO; - break; default: PanicAlert("CCodeWindow::ToggleDLLWindow called with invalid Id"); return; @@ -559,26 +554,26 @@ void CCodeWindow::ToggleDLLWindow(int Id, bool bShow) if (bShow) { // Show window - Win = (wxPanel *)CPluginManager::GetInstance().OpenDebug(Parent, - DLLName.c_str(), (PLUGIN_TYPE)PluginType, bShow); - - if (Win) - { - Win->Show(); - Win->SetId(Id); - Parent->DoAddPage(Win, - iNbAffiliation[Id - IDM_LOGWINDOW], - Parent->bFloatWindow[Id - IDM_LOGWINDOW]); - } + //Win = (wxPanel *)CPluginManager::GetInstance().OpenDebug(Parent, + // DLLName.c_str(), (PLUGIN_TYPE)PluginType, bShow); + + //if (Win) + //{ + // Win->Show(); + // Win->SetId(Id); + // Parent->DoAddPage(Win, + // iNbAffiliation[Id - IDM_LOGWINDOW], + // Parent->bFloatWindow[Id - IDM_LOGWINDOW]); + //} } else { - Win = (wxPanel *)FindWindowById(Id); - if (Win) - { - Parent->DoRemovePage(Win, false); - Win->Destroy(); - } + //Win = (wxPanel *)FindWindowById(Id); + //if (Win) + //{ + // Parent->DoRemovePage(Win, false); + // Win->Destroy(); + //} } GetMenuBar()->FindItem(Id)->Check(bShow && !!Win); } diff --git a/Source/Core/DolphinWX/Dolphin.vcxproj b/Source/Core/DolphinWX/Dolphin.vcxproj index eb406018a964..50bd2701c52a 100644 --- a/Source/Core/DolphinWX/Dolphin.vcxproj +++ b/Source/Core/DolphinWX/Dolphin.vcxproj @@ -131,7 +131,7 @@ Level3 Disabled - ..\Common\Src;..\Core\Src;..\DebuggerWX\Src;..\DebuggerUICommon\Src;..\InputCommon\Src;..\DiscIO\Src;..\..\PluginSpecs;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) + ..\Common\Src;..\AudioCommon\Src;..\Core\Src;..\DebuggerWX\Src;..\DebuggerUICommon\Src;..\InputCommon\Src;..\DiscIO\Src;..\..\PluginSpecs;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreadedDebug stdafx.h @@ -157,7 +157,7 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e / Level3 Disabled - ..\Common\Src;..\Core\Src;..\DebuggerWX\Src;..\DebuggerUICommon\Src;..\InputCommon\Src;..\DiscIO\Src;..\..\PluginSpecs;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) + ..\Common\Src;..\AudioCommon\Src;..\Core\Src;..\DebuggerWX\Src;..\DebuggerUICommon\Src;..\InputCommon\Src;..\DiscIO\Src;..\..\PluginSpecs;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreadedDebug stdafx.h @@ -185,7 +185,7 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e / MaxSpeed true true - ..\Common\Src;..\Core\Src;..\DebuggerWX\Src;..\DebuggerUICommon\Src;..\InputCommon\Src;..\DiscIO\Src;..\..\PluginSpecs;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) + ..\Common\Src;..\AudioCommon\Src;..\Core\Src;..\DebuggerWX\Src;..\DebuggerUICommon\Src;..\InputCommon\Src;..\DiscIO\Src;..\..\PluginSpecs;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded stdafx.h @@ -215,7 +215,7 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e / MaxSpeed true true - ..\Common\Src;..\Core\Src;..\DebuggerWX\Src;..\DebuggerUICommon\Src;..\InputCommon\Src;..\InputUICommon\Src;..\DiscIO\Src;..\..\PluginSpecs;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) + ..\Common\Src;..\AudioCommon\Src;..\Core\Src;..\DebuggerWX\Src;..\DebuggerUICommon\Src;..\InputCommon\Src;..\InputUICommon\Src;..\DiscIO\Src;..\..\PluginSpecs;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) DEBUGFAST;_SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded stdafx.h @@ -245,7 +245,7 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e / MaxSpeed true true - ..\Common\Src;..\Core\Src;..\DebuggerWX\Src;..\DebuggerUICommon\Src;..\InputCommon\Src;..\DiscIO\Src;..\..\PluginSpecs;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) + ..\Common\Src;..\AudioCommon\Src;..\Core\Src;..\DebuggerWX\Src;..\DebuggerUICommon\Src;..\InputCommon\Src;..\DiscIO\Src;..\..\PluginSpecs;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded stdafx.h @@ -275,7 +275,7 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e / MaxSpeed true true - ..\Common\Src;..\Core\Src;..\DebuggerWX\Src;..\DebuggerUICommon\Src;..\InputCommon\Src;..\InputUICommon\Src;..\DiscIO\Src;..\..\PluginSpecs;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) + ..\Common\Src;..\AudioCommon\Src;..\Core\Src;..\DebuggerWX\Src;..\DebuggerUICommon\Src;..\InputCommon\Src;..\InputUICommon\Src;..\DiscIO\Src;..\..\PluginSpecs;..\..\..\Externals\SFML\include;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) DEBUGFAST;_SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded stdafx.h @@ -409,6 +409,18 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e / {3e1339f5-9311-4122-9442-369702e8fcad} + + {9a4c733c-bade-4ac6-b58a-6e274395e90e} + + + {dc7d7af4-ce47-49e8-8b63-265cb6233a49} + + + {1909cd2d-1707-456f-86ca-0df42a727c99} + + + {37d007bd-d66c-4eaf-b56c-bd1aac340a05} + {c87a4178-44f6-49b2-b7aa-c79af1b8c534} @@ -424,9 +436,18 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e / {b6398059-ebb6-4c34-b547-95f365b71ff4} + + {4ed3c8be-91a7-4361-8d46-16d03b678d4c} + {b39ac394-5db5-4da9-9d98-09d46ca3701f} + + {3e5c4e02-1ba9-4776-bdbe-e3f91ffa34cf} + + + {281f6001-d032-4c3b-87af-0b00962b4006} + @@ -434,4 +455,4 @@ xcopy "$(SolutionDir)..\Externals\SDL\$(PlatformName)\*.dll" "$(TargetDir)" /e / - + \ No newline at end of file diff --git a/Source/Core/DolphinWX/Src/ConfigMain.cpp b/Source/Core/DolphinWX/Src/ConfigMain.cpp index fa26061b522f..881a1aacfa95 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.cpp +++ b/Source/Core/DolphinWX/Src/ConfigMain.cpp @@ -30,13 +30,14 @@ #include "Globals.h" // Local #include "ConfigMain.h" -#include "PluginManager.h" #include "ConfigManager.h" #include "SysConf.h" #include "Frame.h" #include "HotkeyDlg.h" #include "Main.h" +#include "VideoBackendBase.h" + #ifdef __APPLE__ #include #endif @@ -176,8 +177,7 @@ EVT_BUTTON(ID_GRAPHIC_CONFIG, CConfigMain::OnConfig) END_EVENT_TABLE() -CConfigMain::CConfigMain(wxWindow* parent, wxWindowID id, const wxString& title, - const wxPoint& position, const wxSize& size, long style) +CConfigMain::CConfigMain(wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& position, const wxSize& size, long style) : wxDialog(parent, id, title, position, size, style) { // Control refreshing of the ISOs list @@ -223,6 +223,7 @@ void CConfigMain::UpdateGUI() CPUEngine->Disable(); LockThreads->Disable(); DSPThread->Disable(); + // Disable stuff on DisplayPage FullscreenResolution->Disable(); @@ -230,16 +231,12 @@ void CConfigMain::UpdateGUI() ProgressiveScan->Disable(); NTSCJ->Disable(); -#if defined _WIN32 || defined __linux__ - // Disable graphics plugin selection - GraphicSelection->Disable(); -#endif - // Disable stuff on AudioPage DSPEngine->Disable(); // Disable stuff on GamecubePage GCSystemLang->Disable(); + // Disable stuff on WiiPage WiiSensBarPos->Disable(); @@ -250,8 +247,15 @@ void CConfigMain::UpdateGUI() WiiAspectRatio->Disable(); WiiSystemLang->Disable(); + // Disable stuff on PathsPage PathsPage->Disable(); + + +#if defined _WIN32 || defined __linux__ + // Disable stuff on PluginsPage + GraphicSelection->Disable(); +#endif } } @@ -376,8 +380,7 @@ void CConfigMain::InitializeGUIValues() UsePanicHandlers->SetValue(startup_params.bUsePanicHandlers); Theme->SetSelection(startup_params.iTheme); // need redesign - for (unsigned int i = 0; i < sizeof(langIds) / sizeof(wxLanguage); i++) - { + for (unsigned int i = 0; i < sizeof(langIds) / sizeof(wxLanguage); i++) { if (langIds[i] == SConfig::GetInstance().m_InterfaceLanguage) { InterfaceLang->SetSelection(i); @@ -407,90 +410,9 @@ void CConfigMain::InitializeGUIValues() GCSystemLang->SetSelection(startup_params.SelectedLanguage); // Gamecube - Devices - wxArrayString SlotDevices; - SlotDevices.Add(_(DEV_NONE_STR)); - SlotDevices.Add(_(DEV_DUMMY_STR)); - SlotDevices.Add(_(EXIDEV_MEMCARD_STR)); - SlotDevices.Add(_(EXIDEV_GECKO_STR)); -#if HAVE_PORTAUDIO - SlotDevices.Add(_(EXIDEV_MIC_STR)); -#endif + // Not here. They use some locals over in CreateGUIControls for initialization, + // which is why they are still there. - wxArrayString SP1Devices; - SP1Devices.Add(_(DEV_NONE_STR)); - SP1Devices.Add(_(DEV_DUMMY_STR)); - SP1Devices.Add(_(EXIDEV_BBA_STR)); - SP1Devices.Add(_(EXIDEV_AM_BB_STR)); - - wxArrayString SIDevices; - SIDevices.Add(_(DEV_NONE_STR)); - SIDevices.Add(_(SIDEV_STDCONT_STR)); - SIDevices.Add(_(SIDEV_GBA_STR)); - SIDevices.Add(_(SIDEV_AM_BB_STR)); - - for (int i = 0; i < 3; ++i) - { - bool isMemcard = false; - - // Add strings to the wxChoice list, the third wxChoice is the SP1 slot - if (i == 2) - GCEXIDevice[i]->Append(SP1Devices); - else - GCEXIDevice[i]->Append(SlotDevices); - - switch (SConfig::GetInstance().m_EXIDevice[i]) - { - case EXIDEVICE_NONE: - GCEXIDevice[i]->SetStringSelection(SlotDevices[0]); - break; - case EXIDEVICE_MEMORYCARD_A: - case EXIDEVICE_MEMORYCARD_B: - isMemcard = GCEXIDevice[i]->SetStringSelection(SlotDevices[2]); - break; - case EXIDEVICE_MIC: - GCEXIDevice[i]->SetStringSelection(SlotDevices[4]); - break; - case EXIDEVICE_ETH: - GCEXIDevice[i]->SetStringSelection(SP1Devices[2]); - break; - case EXIDEVICE_AM_BASEBOARD: - GCEXIDevice[i]->SetStringSelection(SP1Devices[3]); - break; - case EXIDEVICE_GECKO: - GCEXIDevice[i]->SetStringSelection(SlotDevices[3]); - break; - case EXIDEVICE_DUMMY: - default: - GCEXIDevice[i]->SetStringSelection(SlotDevices[1]); - break; - } - if (!isMemcard && i < 2) - GCMemcardPath[i]->Disable(); - } - for (int i = 0; i < 4; ++i) - { - // Add string to the wxChoice list - GCSIDevice[i]->Append(SIDevices); - - switch (SConfig::GetInstance().m_SIDevice[i]) - { - case SI_GC_CONTROLLER: - GCSIDevice[i]->SetStringSelection(SIDevices[1]); - break; - case SI_GBA: - GCSIDevice[i]->SetStringSelection(SIDevices[2]); - break; - case SI_AM_BASEBOARD: - GCSIDevice[i]->SetStringSelection(SIDevices[3]); - break; - default: - GCSIDevice[i]->SetStringSelection(SIDevices[0]); - break; - } - // Remove the AM baseboard from the list, only the first list can select it - if (i == 0) - SIDevices.RemoveAt(SIDevices.GetCount() - 1); - } // Wii - Wiimote WiiSensBarPos->SetSelection(SConfig::GetInstance().m_SYSCONF->GetData("BT.BAR")); @@ -514,11 +436,13 @@ void CConfigMain::InitializeGUIValues() DVDRoot->SetPath(wxString(startup_params.m_strDVDRoot.c_str(), *wxConvCurrent)); ApploaderPath->SetPath(wxString(startup_params.m_strApploader.c_str(), *wxConvCurrent)); - -#if defined _WIN32 || defined __linux__ - // Plugins - FillChoiceBox(GraphicSelection, PLUGIN_TYPE_VIDEO, startup_params.m_strVideoPlugin); -#endif + // video backend list + for (std::vector::const_iterator it = g_available_video_backends.begin(); it != g_available_video_backends.end(); ++it) + { + GraphicSelection->AppendString(wxString::FromUTF8((*it)->GetName().c_str())); + if (*it == g_video_backend) + GraphicSelection->Select(it - g_available_video_backends.begin()); + } } void CConfigMain::InitializeGUITooltips() @@ -556,6 +480,7 @@ void CConfigMain::InitializeGUITooltips() // Audio tooltips EnableDTKMusic->SetToolTip(_("This is used to play music tracks, like BGM.")); EnableThrottle->SetToolTip(_("This is used to control game speed by sound throttle.\nDisabling this could cause abnormal game speed, such as too fast.\nBut sometimes enabling this could cause constant noise.\n\nKeyboard Shortcut : Hold down to instantly disable Throttle.")); + DSPEngine->SetToolTip(_("please someone fill this tooltip i have no idea what to say :D")); FrequencySelection->SetToolTip(_("Changing this will have no effect while the emulator is running!")); BackendSelection->SetToolTip(_("Changing this will have no effect while the emulator is running!")); @@ -571,13 +496,13 @@ void CConfigMain::CreateGUIControls() InitializeGUILists(); // Create the notebook and pages - Notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize); - wxPanel *GeneralPage = new wxPanel(Notebook, ID_GENERALPAGE, wxDefaultPosition, wxDefaultSize); - wxPanel *DisplayPage = new wxPanel(Notebook, ID_DISPLAYPAGE, wxDefaultPosition, wxDefaultSize); - wxPanel *AudioPage = new wxPanel(Notebook, ID_AUDIOPAGE, wxDefaultPosition, wxDefaultSize); - wxPanel *GamecubePage = new wxPanel(Notebook, ID_GAMECUBEPAGE, wxDefaultPosition, wxDefaultSize); - wxPanel *WiiPage = new wxPanel(Notebook, ID_WIIPAGE, wxDefaultPosition, wxDefaultSize); - PathsPage = new wxPanel(Notebook, ID_PATHSPAGE, wxDefaultPosition, wxDefaultSize); + wxNotebook* const Notebook = new wxNotebook(this, ID_NOTEBOOK, wxDefaultPosition, wxDefaultSize); + wxPanel* const GeneralPage = new wxPanel(Notebook, ID_GENERALPAGE, wxDefaultPosition, wxDefaultSize); + wxPanel* const DisplayPage = new wxPanel(Notebook, ID_DISPLAYPAGE, wxDefaultPosition, wxDefaultSize); + wxPanel* const AudioPage = new wxPanel(Notebook, ID_AUDIOPAGE, wxDefaultPosition, wxDefaultSize); + wxPanel* const GamecubePage = new wxPanel(Notebook, ID_GAMECUBEPAGE, wxDefaultPosition, wxDefaultSize); + wxPanel* const WiiPage = new wxPanel(Notebook, ID_WIIPAGE, wxDefaultPosition, wxDefaultSize); + wxPanel* const PathsPage = new wxPanel(Notebook, ID_PATHSPAGE, wxDefaultPosition, wxDefaultSize); Notebook->AddPage(GeneralPage, _("General")); Notebook->AddPage(DisplayPage, _("Display")); @@ -588,30 +513,19 @@ void CConfigMain::CreateGUIControls() // General page // Core Settings - Basic - wxStaticBoxSizer *sbBasic = - new wxStaticBoxSizer(wxVERTICAL, GeneralPage, _("Basic Settings")); - CPUThread = new wxCheckBox(GeneralPage, ID_CPUTHREAD, _("Enable Dual Core (speedup)"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - SkipIdle = new wxCheckBox(GeneralPage, ID_IDLESKIP, _("Enable Idle Skipping (speedup)"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - EnableCheats = new wxCheckBox(GeneralPage, ID_ENABLECHEATS, _("Enable Cheats"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + wxStaticBoxSizer* const sbBasic = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, _("Basic Settings")); + CPUThread = new wxCheckBox(GeneralPage, ID_CPUTHREAD, _("Enable Dual Core (speedup)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + SkipIdle = new wxCheckBox(GeneralPage, ID_IDLESKIP, _("Enable Idle Skipping (speedup)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + EnableCheats = new wxCheckBox(GeneralPage, ID_ENABLECHEATS, _("Enable Cheats"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); // Framelimit - Framelimit = new wxChoice(GeneralPage, ID_FRAMELIMIT, wxDefaultPosition, wxDefaultSize, - arrayStringFor_Framelimit, 0, wxDefaultValidator); - UseFPSForLimiting = new wxCheckBox(GeneralPage, ID_FRAMELIMIT_USEFPSFORLIMITING, - _("Use FPS For Limiting"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + Framelimit = new wxChoice(GeneralPage, ID_FRAMELIMIT, wxDefaultPosition, wxDefaultSize, arrayStringFor_Framelimit, 0, wxDefaultValidator); + UseFPSForLimiting = new wxCheckBox(GeneralPage, ID_FRAMELIMIT_USEFPSFORLIMITING, _("Use FPS For Limiting"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); // Core Settings - Advanced - wxStaticBoxSizer *sbAdvanced = - new wxStaticBoxSizer(wxVERTICAL, GeneralPage, _("Advanced Settings")); - AlwaysHLE_BS2 = new wxCheckBox(GeneralPage, ID_ALWAYS_HLE_BS2, _("Skip GC BIOS"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - CPUEngine = new wxRadioBox(GeneralPage, ID_CPUENGINE, _("CPU Emulator Engine"), - wxDefaultPosition, wxDefaultSize, arrayStringFor_CPUEngine, 0, wxRA_SPECIFY_ROWS); - LockThreads = new wxCheckBox(GeneralPage, ID_LOCKTHREADS, _("Lock threads to cores"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - DSPThread = new wxCheckBox(GeneralPage, ID_DSPTHREAD, _("DSPLLE on thread"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + wxStaticBoxSizer* const sbAdvanced = new wxStaticBoxSizer(wxVERTICAL, GeneralPage, _("Advanced Settings")); + AlwaysHLE_BS2 = new wxCheckBox(GeneralPage, ID_ALWAYS_HLE_BS2, _("Skip GC BIOS"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + CPUEngine = new wxRadioBox(GeneralPage, ID_CPUENGINE, _("CPU Emulator Engine"), wxDefaultPosition, wxDefaultSize, arrayStringFor_CPUEngine, 0, wxRA_SPECIFY_ROWS); + LockThreads = new wxCheckBox(GeneralPage, ID_LOCKTHREADS, _("Lock threads to cores"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + DSPThread = new wxCheckBox(GeneralPage, ID_DSPTHREAD, _("DSPLLE on thread"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); // Populate the General settings sbBasic->Add(CPUThread, 0, wxALL, 5); @@ -628,73 +542,57 @@ void CConfigMain::CreateGUIControls() sbAdvanced->Add(LockThreads, 0, wxALL, 5); sbAdvanced->Add(DSPThread, 0, wxALL, 5); - wxBoxSizer *sGeneralPage = new wxBoxSizer(wxVERTICAL); + wxBoxSizer* const sGeneralPage = new wxBoxSizer(wxVERTICAL); sGeneralPage->Add(sbBasic, 0, wxEXPAND | wxALL, 5); sGeneralPage->Add(sbAdvanced, 0, wxEXPAND | wxALL, 5); GeneralPage->SetSizer(sGeneralPage); - // General display settings sbDisplay = new wxStaticBoxSizer(wxVERTICAL, DisplayPage, _("Emulator Display Settings")); - FullscreenResolution = new wxChoice(DisplayPage, ID_DISPLAY_FULLSCREENRES, - wxDefaultPosition, wxDefaultSize, arrayStringFor_FullscreenResolution, - 0, wxDefaultValidator, arrayStringFor_FullscreenResolution[0]); - WindowWidth = new wxSpinCtrl(DisplayPage, ID_DISPLAY_WINDOWWIDTH, wxEmptyString, - wxDefaultPosition, wxSize(70, -1)); + FullscreenResolution = new wxChoice(DisplayPage, ID_DISPLAY_FULLSCREENRES, wxDefaultPosition, wxDefaultSize, arrayStringFor_FullscreenResolution, 0, wxDefaultValidator, arrayStringFor_FullscreenResolution[0]); + WindowWidth = new wxSpinCtrl(DisplayPage, ID_DISPLAY_WINDOWWIDTH, wxEmptyString, wxDefaultPosition, wxSize(70, -1)); WindowWidth->SetRange(0,3280); - WindowHeight = new wxSpinCtrl(DisplayPage, ID_DISPLAY_WINDOWHEIGHT, - wxEmptyString, wxDefaultPosition, wxSize(70, -1)); + WindowHeight = new wxSpinCtrl(DisplayPage, ID_DISPLAY_WINDOWHEIGHT, wxEmptyString, wxDefaultPosition, wxSize(70, -1)); WindowHeight->SetRange(0,2048); - WindowAutoSize = new wxCheckBox(DisplayPage, ID_DISPLAY_AUTOSIZE, _("Auto"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - Fullscreen = new wxCheckBox(DisplayPage, ID_DISPLAY_FULLSCREEN, - _("Start Renderer in Fullscreen"), wxDefaultPosition, wxDefaultSize, - 0, wxDefaultValidator); + WindowAutoSize = new wxCheckBox(DisplayPage, ID_DISPLAY_AUTOSIZE, _("Auto"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + Fullscreen = new wxCheckBox(DisplayPage, ID_DISPLAY_FULLSCREEN, _("Start Renderer in Fullscreen"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); HideCursor = new wxCheckBox(DisplayPage, ID_DISPLAY_HIDECURSOR, _("Hide Mouse Cursor")); - RenderToMain = new wxCheckBox(DisplayPage, ID_DISPLAY_RENDERTOMAIN, - _("Render to Main Window"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - ProgressiveScan = new wxCheckBox(DisplayPage, ID_DISPLAY_PROGSCAN, - _("Enable Progressive Scan"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - NTSCJ = new wxCheckBox(DisplayPage, ID_DISPLAY_NTSCJ, _("Set Console as NTSC-J"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - -#if defined _WIN32 || defined __linux__ - // GFX Plugin Selection - GraphicSelection = new wxChoice(DisplayPage, ID_GRAPHIC_CB, - wxDefaultPosition, wxDefaultSize, 0, NULL, 0, wxDefaultValidator); - GraphicConfig = new wxButton(DisplayPage, ID_GRAPHIC_CONFIG, _("Config..."), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); -#endif + RenderToMain = new wxCheckBox(DisplayPage, ID_DISPLAY_RENDERTOMAIN, _("Render to Main Window"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + ProgressiveScan = new wxCheckBox(DisplayPage, ID_DISPLAY_PROGSCAN, _("Enable Progressive Scan"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + NTSCJ = new wxCheckBox(DisplayPage, ID_DISPLAY_NTSCJ, _("Set Console as NTSC-J"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); // Interface Language - // TODO : Do these really belong to the display page? - InterfaceLang = new wxChoice(DisplayPage, ID_INTERFACE_LANG, wxDefaultPosition, - wxDefaultSize, arrayStringFor_InterfaceLang, 0, wxDefaultValidator); + InterfaceLang = new wxChoice(DisplayPage, ID_INTERFACE_LANG, wxDefaultPosition, wxDefaultSize, arrayStringFor_InterfaceLang, 0, wxDefaultValidator); // Hotkey configuration - HotkeyConfig = new wxButton(DisplayPage, ID_HOTKEY_CONFIG, _("Hotkeys"), - wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator); + // TODO : doesn't really belong to the display page, heh. + HotkeyConfig = new wxButton(DisplayPage, ID_HOTKEY_CONFIG, _("Hotkeys"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator); // Themes - this should really be a wxChoice... - Theme = new wxRadioBox(DisplayPage, ID_INTERFACE_THEME, _("Theme"), - wxDefaultPosition, wxDefaultSize, arrayStringFor_Themes, 1, wxRA_SPECIFY_ROWS); + Theme = new wxRadioBox(DisplayPage, ID_INTERFACE_THEME, _("Theme"), wxDefaultPosition, wxDefaultSize, arrayStringFor_Themes, 1, wxRA_SPECIFY_ROWS); // Interface settings sbInterface = new wxStaticBoxSizer(wxVERTICAL, DisplayPage, _("Interface Settings")); - ConfirmStop = new wxCheckBox(DisplayPage, ID_INTERFACE_CONFIRMSTOP, _("Confirm On Stop"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - UsePanicHandlers = new wxCheckBox(DisplayPage, ID_INTERFACE_USEPANICHANDLERS, - _("Use Panic Handlers"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + ConfirmStop = new wxCheckBox(DisplayPage, ID_INTERFACE_CONFIRMSTOP, _("Confirm On Stop"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + UsePanicHandlers = new wxCheckBox(DisplayPage, ID_INTERFACE_USEPANICHANDLERS, _("Use Panic Handlers"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); // Populate the Display page wxBoxSizer* sDisplayRes = new wxBoxSizer(wxHORIZONTAL); sDisplayRes->Add(TEXT_BOX(DisplayPage, _("Fullscreen Display Resolution:")), - 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - sDisplayRes->Add(FullscreenResolution, 0, wxEXPAND | wxALL, 5); + 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); + sDisplayRes->Add(FullscreenResolution, 0, wxEXPAND, 5); sbDisplay->Add(sDisplayRes, 0, wxALL, 5); + + // backend + wxBoxSizer* svidbackend = new wxBoxSizer(wxHORIZONTAL); + svidbackend->Add(TEXT_BOX(DisplayPage, _("Video Backend:")), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); + GraphicSelection = new wxChoice(DisplayPage, ID_GRAPHIC_CB, wxDefaultPosition, wxDefaultSize, 0, NULL, 0, wxDefaultValidator); + svidbackend->Add(GraphicSelection, 0, wxALIGN_CENTER_VERTICAL, 5); + sbDisplay->Add(svidbackend, 0, wxLEFT, 5); + wxBoxSizer* sDisplaySize = new wxBoxSizer(wxHORIZONTAL); - sDisplaySize->Add(TEXT_BOX(DisplayPage, _("Window Size:")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - sDisplaySize->Add(WindowWidth, 0, wxEXPAND | wxALL, 5); - sDisplaySize->Add(TEXT_BOX(DisplayPage, wxT("x")), 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); - sDisplaySize->Add(WindowHeight, 0, wxEXPAND | wxALL, 5); - sDisplaySize->Add(WindowAutoSize, 0, wxALIGN_CENTER_VERTICAL | wxALL, 5); + sDisplaySize->Add(TEXT_BOX(DisplayPage, _("Window Size:")), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); + sDisplaySize->Add(WindowWidth, 0, wxEXPAND | wxRIGHT, 5); + sDisplaySize->Add(TEXT_BOX(DisplayPage, wxT("x")), 0, wxALIGN_CENTER_VERTICAL | wxRIGHT, 5); + sDisplaySize->Add(WindowHeight, 0, wxEXPAND | wxRIGHT, 5); + sDisplaySize->Add(WindowAutoSize, 0, wxALIGN_CENTER_VERTICAL, 5); sbDisplay->Add(sDisplaySize, 0, wxALL, 5); sbDisplay->Add(Fullscreen, 0, wxEXPAND | wxALL, 5); sbDisplay->Add(HideCursor, 0, wxALL, 5); @@ -702,13 +600,6 @@ void CConfigMain::CreateGUIControls() sbDisplay->Add(ProgressiveScan, 0, wxEXPAND | wxALL, 5); sbDisplay->Add(NTSCJ, 0, wxEXPAND | wxALL, 5); -#if defined _WIN32 || defined __linux__ - wxStaticBoxSizer *sbGraphicsPlugin = - new wxStaticBoxSizer(wxHORIZONTAL, DisplayPage, _("Graphics Plugin")); - sbGraphicsPlugin->Add(GraphicSelection, 1, wxEXPAND|wxALL, 5); - sbGraphicsPlugin->Add(GraphicConfig, 0, wxALL, 5); -#endif - sbInterface->Add(ConfirmStop, 0, wxALL, 5); sbInterface->Add(UsePanicHandlers, 0, wxALL, 5); sbInterface->Add(Theme, 0, wxEXPAND | wxALL, 5); @@ -721,26 +612,17 @@ void CConfigMain::CreateGUIControls() sDisplayPage = new wxBoxSizer(wxVERTICAL); sDisplayPage->Add(sbDisplay, 0, wxEXPAND | wxALL, 5); -#if defined _WIN32 || defined __linux__ - sDisplayPage->Add(sbGraphicsPlugin, 0, wxEXPAND | wxALL, 5); -#endif sDisplayPage->Add(sbInterface, 0, wxEXPAND | wxALL, 5); DisplayPage->SetSizer(sDisplayPage); // Audio page - DSPEngine = new wxRadioBox(AudioPage, ID_DSPENGINE, _("DSP Emulator Engine"), - wxDefaultPosition, wxDefaultSize, arrayStringFor_DSPEngine, 0, wxRA_SPECIFY_ROWS); - EnableDTKMusic = new wxCheckBox(AudioPage, ID_ENABLE_DTK_MUSIC, _("Enable DTK Music"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - EnableThrottle = new wxCheckBox(AudioPage, ID_ENABLE_THROTTLE, _("Enable Audio Throttle"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - VolumeSlider = new wxSlider(AudioPage, ID_VOLUME, 0, 1, 100, - wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL|wxSL_INVERSE); - VolumeText = new wxStaticText(AudioPage, wxID_ANY, wxT(""), - wxDefaultPosition, wxDefaultSize, 0); - BackendSelection = new wxChoice(AudioPage, ID_BACKEND, wxDefaultPosition, - wxDefaultSize, wxArrayBackends, 0, wxDefaultValidator, wxEmptyString); + DSPEngine = new wxRadioBox(AudioPage, ID_DSPENGINE, _("DSP Emulator Engine"), wxDefaultPosition, wxDefaultSize, arrayStringFor_DSPEngine, 0, wxRA_SPECIFY_ROWS); + EnableDTKMusic = new wxCheckBox(AudioPage, ID_ENABLE_DTK_MUSIC, _("Enable DTK Music"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + EnableThrottle = new wxCheckBox(AudioPage, ID_ENABLE_THROTTLE, _("Enable Audio Throttle"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + VolumeSlider = new wxSlider(AudioPage, ID_VOLUME, 0, 1, 100, wxDefaultPosition, wxDefaultSize, wxSL_VERTICAL|wxSL_INVERSE); + VolumeText = new wxStaticText(AudioPage, wxID_ANY, wxT(""), wxDefaultPosition, wxDefaultSize, 0); + BackendSelection = new wxChoice(AudioPage, ID_BACKEND, wxDefaultPosition, wxDefaultSize, wxArrayBackends, 0, wxDefaultValidator, wxEmptyString); FrequencySelection = new wxChoice(AudioPage, ID_FREQUENCY); FrequencySelection->Append(_("48,000 Hz")); FrequencySelection->Append(_("32,000 Hz")); @@ -775,26 +657,66 @@ void CConfigMain::CreateGUIControls() AudioPage->SetSizerAndFit(sAudioPage); + // TODO : Warning the following code hurts // Gamecube page // IPL settings sbGamecubeIPLSettings = new wxStaticBoxSizer(wxVERTICAL, GamecubePage, _("IPL Settings")); - GCSystemLang = new wxChoice(GamecubePage, ID_GC_SRAM_LNG, wxDefaultPosition, - wxDefaultSize, arrayStringFor_GCSystemLang, 0, wxDefaultValidator); + GCSystemLang = new wxChoice(GamecubePage, ID_GC_SRAM_LNG, wxDefaultPosition, wxDefaultSize, arrayStringFor_GCSystemLang, 0, wxDefaultValidator); // Device settings // EXI Devices - wxStaticBoxSizer *sbGamecubeDeviceSettings = - new wxStaticBoxSizer(wxVERTICAL, GamecubePage, _("Device Settings")); + wxStaticBoxSizer *sbGamecubeDeviceSettings = new wxStaticBoxSizer(wxVERTICAL, GamecubePage, _("Device Settings")); wxStaticText* GCEXIDeviceText[3]; GCEXIDeviceText[0] = TEXT_BOX(GamecubePage, _("Slot A")); GCEXIDeviceText[1] = TEXT_BOX(GamecubePage, _("Slot B")); GCEXIDeviceText[2] = TEXT_BOX(GamecubePage, wxT("SP1 ")); - GCEXIDevice[0] = new wxChoice(GamecubePage, ID_GC_EXIDEVICE_SLOTA); - GCEXIDevice[1] = new wxChoice(GamecubePage, ID_GC_EXIDEVICE_SLOTB); - GCEXIDevice[2] = new wxChoice(GamecubePage, ID_GC_EXIDEVICE_SP1); - GCMemcardPath[0] = new wxButton(GamecubePage, ID_GC_EXIDEVICE_SLOTA_PATH, wxT("..."), - wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator); - GCMemcardPath[1] = new wxButton(GamecubePage, ID_GC_EXIDEVICE_SLOTB_PATH, wxT("..."), - wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator); + const wxString SlotDevices[] = {_(DEV_NONE_STR), _(DEV_DUMMY_STR), _(EXIDEV_MEMCARD_STR), _(EXIDEV_GECKO_STR) + #if HAVE_PORTAUDIO + , _(EXIDEV_MIC_STR) + #endif + }; + static const int numSlotDevices = sizeof(SlotDevices)/sizeof(wxString); + const wxString SP1Devices[] = { _(DEV_NONE_STR), _(DEV_DUMMY_STR), _(EXIDEV_BBA_STR), _(EXIDEV_AM_BB_STR) }; + static const int numSP1Devices = sizeof(SP1Devices)/sizeof(wxString); + GCEXIDevice[0] = new wxChoice(GamecubePage, ID_GC_EXIDEVICE_SLOTA, wxDefaultPosition, wxDefaultSize, numSlotDevices, SlotDevices, 0, wxDefaultValidator); + GCEXIDevice[1] = new wxChoice(GamecubePage, ID_GC_EXIDEVICE_SLOTB, wxDefaultPosition, wxDefaultSize, numSlotDevices, SlotDevices, 0, wxDefaultValidator); + GCEXIDevice[2] = new wxChoice(GamecubePage, ID_GC_EXIDEVICE_SP1, wxDefaultPosition, wxDefaultSize, numSP1Devices, SP1Devices, 0, wxDefaultValidator); + GCMemcardPath[0] = new wxButton(GamecubePage, ID_GC_EXIDEVICE_SLOTA_PATH, wxT("..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator); + GCMemcardPath[1] = new wxButton(GamecubePage, ID_GC_EXIDEVICE_SLOTB_PATH, wxT("..."), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT, wxDefaultValidator); + + // Can't move this one without making the 4 const's etc. above class members/fields, + // TODO : lies, wxArrayString + wxChoice->Create. + for (int i = 0; i < 3; ++i) + { + bool isMemcard = false; + switch (SConfig::GetInstance().m_EXIDevice[i]) + { + case EXIDEVICE_NONE: + GCEXIDevice[i]->SetStringSelection(SlotDevices[0]); + break; + case EXIDEVICE_MEMORYCARD_A: + case EXIDEVICE_MEMORYCARD_B: + isMemcard = GCEXIDevice[i]->SetStringSelection(SlotDevices[2]); + break; + case EXIDEVICE_MIC: + GCEXIDevice[i]->SetStringSelection(SlotDevices[4]); + break; + case EXIDEVICE_ETH: + GCEXIDevice[i]->SetStringSelection(SP1Devices[2]); + break; + case EXIDEVICE_AM_BASEBOARD: + GCEXIDevice[i]->SetStringSelection(SP1Devices[3]); + break; + case EXIDEVICE_GECKO: + GCEXIDevice[i]->SetStringSelection(SlotDevices[3]); + break; + case EXIDEVICE_DUMMY: + default: + GCEXIDevice[i]->SetStringSelection(SlotDevices[1]); + break; + } + if (!isMemcard && i < 2) + GCMemcardPath[i]->Disable(); + } //SI Devices wxStaticText* GCSIDeviceText[4]; @@ -802,11 +724,33 @@ void CConfigMain::CreateGUIControls() GCSIDeviceText[1] = TEXT_BOX(GamecubePage, _("Port 2")); GCSIDeviceText[2] = TEXT_BOX(GamecubePage, _("Port 3")); GCSIDeviceText[3] = TEXT_BOX(GamecubePage, _("Port 4")); - GCSIDevice[0] = new wxChoice(GamecubePage, ID_GC_SIDEVICE0); - GCSIDevice[1] = new wxChoice(GamecubePage, ID_GC_SIDEVICE1); - GCSIDevice[2] = new wxChoice(GamecubePage, ID_GC_SIDEVICE2); - GCSIDevice[3] = new wxChoice(GamecubePage, ID_GC_SIDEVICE3); + // SIDEV_AM_BB_STR must be last! + const wxString SIDevices[] = {_(DEV_NONE_STR),_(SIDEV_STDCONT_STR),_(SIDEV_GBA_STR),_(SIDEV_AM_BB_STR)}; + static const int numSIDevices = sizeof(SIDevices)/sizeof(wxString); + GCSIDevice[0] = new wxChoice(GamecubePage, ID_GC_SIDEVICE0, wxDefaultPosition, wxDefaultSize, numSIDevices, SIDevices, 0, wxDefaultValidator); + GCSIDevice[1] = new wxChoice(GamecubePage, ID_GC_SIDEVICE1, wxDefaultPosition, wxDefaultSize, numSIDevices - 1, SIDevices, 0, wxDefaultValidator); + GCSIDevice[2] = new wxChoice(GamecubePage, ID_GC_SIDEVICE2, wxDefaultPosition, wxDefaultSize, numSIDevices - 1, SIDevices, 0, wxDefaultValidator); + GCSIDevice[3] = new wxChoice(GamecubePage, ID_GC_SIDEVICE3, wxDefaultPosition, wxDefaultSize, numSIDevices - 1, SIDevices, 0, wxDefaultValidator); + // Can't move this one without making the 2 const's etc. above class members/fields. + for (int i = 0; i < 4; ++i) + { + switch (SConfig::GetInstance().m_SIDevice[i]) + { + case SI_GC_CONTROLLER: + GCSIDevice[i]->SetStringSelection(SIDevices[1]); + break; + case SI_GBA: + GCSIDevice[i]->SetStringSelection(SIDevices[2]); + break; + case SI_AM_BASEBOARD: + GCSIDevice[i]->SetStringSelection(SIDevices[3]); + break; + default: + GCSIDevice[i]->SetStringSelection(SIDevices[0]); + break; + } + } // Populate the Gamecube page sGamecubeIPLSettings = new wxGridBagSizer(); @@ -840,30 +784,21 @@ void CConfigMain::CreateGUIControls() // Wii page // Wiimote Settings sbWiimoteSettings = new wxStaticBoxSizer(wxHORIZONTAL, WiiPage, _("Wiimote Settings")); - WiiSensBarPos = new wxChoice(WiiPage, ID_WII_BT_BAR, wxDefaultPosition, - wxDefaultSize, arrayStringFor_WiiSensBarPos, 0, wxDefaultValidator); + WiiSensBarPos = new wxChoice(WiiPage, ID_WII_BT_BAR, wxDefaultPosition, wxDefaultSize, arrayStringFor_WiiSensBarPos, 0, wxDefaultValidator); WiiSensBarSens = new wxSlider(WiiPage, ID_WII_BT_SENS, 0, 0, 4); - WiimoteMotor = new wxCheckBox(WiiPage, ID_WII_BT_MOT, _("Wiimote Motor"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + WiimoteMotor = new wxCheckBox(WiiPage, ID_WII_BT_MOT, _("Wiimote Motor"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); // Misc Settings sbWiiIPLSettings = new wxStaticBoxSizer(wxVERTICAL, WiiPage, _("Misc Settings")); - WiiScreenSaver = new wxCheckBox(WiiPage, ID_WII_IPL_SSV, - _("Enable Screen Saver (burn-in reduction)"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - WiiEuRGB60 = new wxCheckBox(WiiPage, ID_WII_IPL_E60, _("Use EuRGB60 Mode (PAL60)"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - WiiAspectRatio = new wxChoice(WiiPage, ID_WII_IPL_AR, wxDefaultPosition, - wxDefaultSize, arrayStringFor_WiiAspectRatio, 0, wxDefaultValidator); - WiiSystemLang = new wxChoice(WiiPage, ID_WII_IPL_LNG, wxDefaultPosition, - wxDefaultSize, arrayStringFor_WiiSystemLang, 0, wxDefaultValidator); + WiiScreenSaver = new wxCheckBox(WiiPage, ID_WII_IPL_SSV, _("Enable Screen Saver (burn-in reduction)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + WiiEuRGB60 = new wxCheckBox(WiiPage, ID_WII_IPL_E60, _("Use EuRGB60 Mode (PAL60)"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + WiiAspectRatio = new wxChoice(WiiPage, ID_WII_IPL_AR, wxDefaultPosition, wxDefaultSize, arrayStringFor_WiiAspectRatio, 0, wxDefaultValidator); + WiiSystemLang = new wxChoice(WiiPage, ID_WII_IPL_LNG, wxDefaultPosition, wxDefaultSize, arrayStringFor_WiiSystemLang, 0, wxDefaultValidator); // Device Settings sbWiiDeviceSettings = new wxStaticBoxSizer(wxVERTICAL, WiiPage, _("Device Settings")); - WiiSDCard = new wxCheckBox(WiiPage, ID_WII_SD_CARD, _("Insert SD Card"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - WiiKeyboard = new wxCheckBox(WiiPage, ID_WII_KEYBOARD, _("Connect USB Keyboard"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + WiiSDCard = new wxCheckBox(WiiPage, ID_WII_SD_CARD, _("Insert SD Card"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + WiiKeyboard = new wxCheckBox(WiiPage, ID_WII_KEYBOARD, _("Connect USB Keyboard"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); // Populate the Wii Page sWiimoteSettings = new wxGridBagSizer(); @@ -899,27 +834,19 @@ void CConfigMain::CreateGUIControls() // Paths page sbISOPaths = new wxStaticBoxSizer(wxVERTICAL, PathsPage, _("ISO Directories")); - ISOPaths = new wxListBox(PathsPage, ID_ISOPATHS, wxDefaultPosition, - wxDefaultSize, arrayStringFor_ISOPaths, wxLB_SINGLE, wxDefaultValidator); - RecursiveISOPath = new wxCheckBox(PathsPage, ID_RECURSIVEISOPATH, _("Search Subfolders"), - wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); - AddISOPath = new wxButton(PathsPage, ID_ADDISOPATH, _("Add..."), - wxDefaultPosition, wxDefaultSize, 0); - RemoveISOPath = new wxButton(PathsPage, ID_REMOVEISOPATH, _("Remove"), - wxDefaultPosition, wxDefaultSize, 0); + ISOPaths = new wxListBox(PathsPage, ID_ISOPATHS, wxDefaultPosition, wxDefaultSize, arrayStringFor_ISOPaths, wxLB_SINGLE, wxDefaultValidator); + RecursiveISOPath = new wxCheckBox(PathsPage, ID_RECURSIVEISOPATH, _("Search Subfolders"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + AddISOPath = new wxButton(PathsPage, ID_ADDISOPATH, _("Add..."), wxDefaultPosition, wxDefaultSize, 0); + RemoveISOPath = new wxButton(PathsPage, ID_REMOVEISOPATH, _("Remove"), wxDefaultPosition, wxDefaultSize, 0); RemoveISOPath->Enable(false); - DefaultISO = new wxFilePickerCtrl(PathsPage, ID_DEFAULTISO, wxEmptyString, - _("Choose a default ISO:"), - _("All GC/Wii images (gcm, iso, ciso, gcz)") + wxString::Format(wxT("|*.gcm;*.iso;*.ciso;*.gcz|%s"), - wxGetTranslation(wxALL_FILES)), - wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_OPEN); - DVDRoot = new wxDirPickerCtrl(PathsPage, ID_DVDROOT, wxEmptyString, - _("Choose a DVD root directory:"), wxDefaultPosition, wxDefaultSize, wxDIRP_USE_TEXTCTRL); - ApploaderPath = new wxFilePickerCtrl(PathsPage, ID_APPLOADERPATH, wxEmptyString, - _("Choose file to use as apploader: (applies to discs constructed from directories only)"), - _("apploader (.img)") + wxString::Format(wxT("|*.img|%s"), wxGetTranslation(wxALL_FILES)), - wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_OPEN); + DefaultISO = new wxFilePickerCtrl(PathsPage, ID_DEFAULTISO, wxEmptyString, _("Choose a default ISO:"), + _("All GC/Wii images (gcm, iso, ciso, gcz)") + wxString::Format(wxT("|*.gcm;*.iso;*.ciso;*.gcz|%s"), wxGetTranslation(wxALL_FILES)), + wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_OPEN); + DVDRoot = new wxDirPickerCtrl(PathsPage, ID_DVDROOT, wxEmptyString, _("Choose a DVD root directory:"), wxDefaultPosition, wxDefaultSize, wxDIRP_USE_TEXTCTRL); + ApploaderPath = new wxFilePickerCtrl(PathsPage, ID_APPLOADERPATH, wxEmptyString, _("Choose file to use as apploader: (applies to discs constructed from directories only)"), + _("apploader (.img)") + wxString::Format(wxT("|*.img|%s"), wxGetTranslation(wxALL_FILES)), + wxDefaultPosition, wxDefaultSize, wxFLP_USE_TEXTCTRL|wxFLP_OPEN); // Populate the settings sbISOPaths->Add(ISOPaths, 1, wxEXPAND|wxALL, 0); @@ -948,6 +875,25 @@ void CConfigMain::CreateGUIControls() sPathsPage->Add(sOtherPaths, 0, wxEXPAND|wxALL, 5); PathsPage->SetSizer(sPathsPage); + +#if defined _WIN32 || defined __linux__ + // Plugins page + //sbGraphicsPlugin = new wxStaticBoxSizer(wxHORIZONTAL, PluginsPage, _("Graphics")); + //GraphicSelection = new wxChoice(PluginsPage, ID_GRAPHIC_CB, wxDefaultPosition, wxDefaultSize, 0, NULL, 0, wxDefaultValidator); + //GraphicConfig = new wxButton(PluginsPage, ID_GRAPHIC_CONFIG, _("Config..."), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator); + + //// Populate the settings + //sbGraphicsPlugin->Add(GraphicSelection, 1, wxEXPAND|wxALL, 5); + //sbGraphicsPlugin->Add(GraphicConfig, 0, wxALL, 5); + + //// Populate the Plugins page + //sPluginsPage = new wxBoxSizer(wxVERTICAL); + //sPluginsPage->Add(sbGraphicsPlugin, 0, wxEXPAND|wxALL, 5); + + //PluginsPage->SetSizer(sPluginsPage); +#endif + + m_Ok = new wxButton(this, wxID_OK); wxBoxSizer* sButtons = new wxBoxSizer(wxHORIZONTAL); @@ -1102,13 +1048,14 @@ void CConfigMain::AudioSettingsChanged(wxCommandEvent& event) ac_Config.m_EnableJIT = DSPEngine->GetSelection() == 1; ac_Config.Update(); break; + case ID_BACKEND: + VolumeSlider->Enable(SupportsVolumeChanges(std::string(BackendSelection->GetStringSelection().mb_str()))); + break; case ID_VOLUME: ac_Config.m_Volume = VolumeSlider->GetValue(); ac_Config.Update(); VolumeText->SetLabel(wxString::Format(wxT("%d %%"), VolumeSlider->GetValue())); break; - case ID_BACKEND: - VolumeSlider->Enable(SupportsVolumeChanges(std::string(BackendSelection->GetStringSelection().mb_str()))); default: ac_Config.m_EnableDTKMusic = EnableDTKMusic->GetValue(); ac_Config.m_EnableThrottle = EnableThrottle->GetValue(); @@ -1388,88 +1335,16 @@ void CConfigMain::ApploaderPathChanged(wxFileDirPickerEvent& WXUNUSED (event)) // Plugin settings -void CConfigMain::OnSelectionChanged(wxCommandEvent& WXUNUSED (event)) +void CConfigMain::OnSelectionChanged(wxCommandEvent& ev) { - // Update plugin filenames - if (GetFilename(GraphicSelection, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin)) - CPluginManager::GetInstance().FreeVideo(); + g_video_backend = g_available_video_backends[ev.GetInt()]; + SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin = g_video_backend->GetName(); } -void CConfigMain::OnConfig(wxCommandEvent& event) +void CConfigMain::OnConfig(wxCommandEvent&) { - switch (event.GetId()) - { - case ID_GRAPHIC_CONFIG: - CallConfig(GraphicSelection); - break; - } -} - - -void CConfigMain::CallConfig(wxChoice* _pChoice) -{ - int Index = _pChoice->GetSelection(); - INFO_LOG(CONSOLE, "CallConfig: %i\n", Index); - if (Index >= 0) - { - const CPluginInfo* pInfo = static_cast(_pChoice->GetClientData(Index)); - if (pInfo != NULL) - { - #ifdef _WIN32 - // Make sure only one dialog can be opened at a time in Windows, - // but is unnecessary and looks bad in linux. - Disable(); - #endif - CPluginManager::GetInstance().OpenConfig(this, - pInfo->GetFilename().c_str(), pInfo->GetPluginInfo().Type); - #ifdef _WIN32 - Enable(); - Raise(); - #endif - } - } -} - -void CConfigMain::FillChoiceBox(wxChoice* _pChoice, int _PluginType, const std::string& _SelectFilename) -{ - _pChoice->Clear(); - - int Index = -1; - const CPluginInfos& rInfos = CPluginManager::GetInstance().GetPluginInfos(); - - for (size_t i = 0; i < rInfos.size(); i++) - { - const PLUGIN_INFO& rPluginInfo = rInfos[i].GetPluginInfo(); - - if (rPluginInfo.Type == _PluginType) - { - wxString temp; - temp = wxGetTranslation(wxString::FromUTF8(rInfos[i].GetPluginInfo().Name)); - int NewIndex = _pChoice->Append(temp, (void*)&rInfos[i]); - - if (rInfos[i].GetFilename() == _SelectFilename) - { - Index = NewIndex; - } - } - } - - _pChoice->Select(Index); -} - -bool CConfigMain::GetFilename(wxChoice* _pChoice, std::string& _rFilename) -{ - _rFilename.clear(); - int Index = _pChoice->GetSelection(); - if (Index >= 0) - { - const CPluginInfo* pInfo = static_cast(_pChoice->GetClientData(Index)); - _rFilename = pInfo->GetFilename(); - INFO_LOG(CONSOLE, "GetFilename: %i %s\n", Index, _rFilename.c_str()); - return(true); - } - - return(false); + if (g_video_backend) + g_video_backend->ShowConfig(this); } // Search for avaliable resolutions @@ -1537,4 +1412,4 @@ void CConfigMain::AddResolutions() } } #endif -} \ No newline at end of file +} diff --git a/Source/Core/DolphinWX/Src/ConfigMain.h b/Source/Core/DolphinWX/Src/ConfigMain.h index 512adb4f2edc..fa838c375962 100644 --- a/Source/Core/DolphinWX/Src/ConfigMain.h +++ b/Source/Core/DolphinWX/Src/ConfigMain.h @@ -57,7 +57,6 @@ class CConfigMain : public wxDialog ID_GAMECUBEPAGE, ID_WIIPAGE, ID_PATHSPAGE, - ID_PLUGINPAGE, }; private: @@ -75,7 +74,6 @@ class CConfigMain : public wxDialog ID_LOCKTHREADS, ID_DSPTHREAD, - ID_DISPLAY_FULLSCREENRES, ID_DISPLAY_WINDOWWIDTH, ID_DISPLAY_WINDOWHEIGHT, @@ -102,7 +100,6 @@ class CConfigMain : public wxDialog ID_INTERFACE_LANG, ID_HOTKEY_CONFIG, - ID_GC_SRAM_LNG, ID_GC_EXIDEVICE_SLOTA, @@ -298,9 +295,6 @@ class CConfigMain : public wxDialog void DVDRootChanged(wxFileDirPickerEvent& event); void ApploaderPathChanged(wxFileDirPickerEvent& WXUNUSED (event)); - void FillChoiceBox(wxChoice* _pChoice, int _PluginType, const std::string& _SelectFilename); - void CallConfig(wxChoice* _pChoice); - bool GetFilename(wxChoice* _pChoice, std::string& _rFilename); DECLARE_EVENT_TABLE(); }; #endif diff --git a/Source/Core/DolphinWX/Src/Frame.cpp b/Source/Core/DolphinWX/Src/Frame.cpp index 13d73d16fe60..cdb5d8cc4eba 100644 --- a/Source/Core/DolphinWX/Src/Frame.cpp +++ b/Source/Core/DolphinWX/Src/Frame.cpp @@ -31,7 +31,6 @@ #include "Globals.h" // Local #include "Frame.h" #include "ConfigMain.h" -#include "PluginManager.h" #include "CheatsWindow.h" #include "AboutDolphin.h" #include "GameListCtrl.h" @@ -46,6 +45,8 @@ #include "State.h" #include "VolumeHandler.h" +#include "VideoBackendBase.h" + #include // wxWidgets // Resources @@ -429,9 +430,6 @@ CFrame::CFrame(wxFrame* parent, m_LogWindow->Hide(); m_LogWindow->Disable(); - // Create list of available plugins for the configuration window - CPluginManager::GetInstance().ScanForPlugins(); - // Setup perspectives if (g_pCodeWindow) { diff --git a/Source/Core/DolphinWX/Src/FrameAui.cpp b/Source/Core/DolphinWX/Src/FrameAui.cpp index 9fa0b8ea17f6..ed51bc7cf2c9 100644 --- a/Source/Core/DolphinWX/Src/FrameAui.cpp +++ b/Source/Core/DolphinWX/Src/FrameAui.cpp @@ -27,7 +27,6 @@ #include "Globals.h" // Local #include "Frame.h" #include "ConfigMain.h" -#include "PluginManager.h" #include "CheatsWindow.h" #include "AboutDolphin.h" #include "GameListCtrl.h" diff --git a/Source/Core/DolphinWX/Src/FrameTools.cpp b/Source/Core/DolphinWX/Src/FrameTools.cpp index c8ef0a1a9448..c062c7772b22 100644 --- a/Source/Core/DolphinWX/Src/FrameTools.cpp +++ b/Source/Core/DolphinWX/Src/FrameTools.cpp @@ -35,11 +35,11 @@ Core::GetWindowHandle(). #include "FileUtil.h" #include "FileSearch.h" #include "Timer.h" +#include "VideoBackendBase.h" #include "Globals.h" // Local #include "Frame.h" #include "ConfigMain.h" -#include "PluginManager.h" #include "MemcardManager.h" #include "CheatsWindow.h" #include "LuaWindow.h" @@ -979,7 +979,7 @@ void CFrame::DoStop() (wxObject*)0, this); if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) m_RenderParent->SetCursor(wxCURSOR_ARROW); - DoFullscreen(FALSE); + DoFullscreen(false); if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bRenderToMain) m_RenderFrame->Destroy(); m_RenderParent = NULL; @@ -1051,18 +1051,8 @@ void CFrame::OnConfigMain(wxCommandEvent& WXUNUSED (event)) void CFrame::OnPluginGFX(wxCommandEvent& WXUNUSED (event)) { - #ifdef _WIN32 - Disable(); // Fake a modal dialog - #endif - CPluginManager::GetInstance().OpenConfig( - this, - SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin.c_str(), - PLUGIN_TYPE_VIDEO - ); - #ifdef _WIN32 - Enable(); - Raise(); - #endif + if (g_video_backend) + g_video_backend->ShowConfig(this); } void CFrame::OnPluginDSP(wxCommandEvent& WXUNUSED (event)) diff --git a/Source/Core/DolphinWX/Src/Main.cpp b/Source/Core/DolphinWX/Src/Main.cpp index 35f88421e69b..193c51729da1 100644 --- a/Source/Core/DolphinWX/Src/Main.cpp +++ b/Source/Core/DolphinWX/Src/Main.cpp @@ -31,7 +31,6 @@ #include "Setup.h" #include "Host.h" // Core -#include "PluginManager.h" #include "HW/Wiimote.h" #include "Globals.h" // Local @@ -43,6 +42,8 @@ #include "BootManager.h" #include "Frame.h" +#include "VideoBackendBase.h" + #include // ------------ @@ -283,13 +284,15 @@ bool DolphinApp::OnInit() LogManager::Init(); SConfig::Init(); - CPluginManager::Init(); + VideoBackend::PopulateList(); WiimoteReal::LoadSettings(); if (selectVideoPlugin && videoPluginFilename != wxEmptyString) SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin = std::string(videoPluginFilename.mb_str()); + VideoBackend::ActivateBackend(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strVideoPlugin); + // Enable the PNG image handler for screenshots wxImage::AddHandler(new wxPNGHandler); @@ -420,7 +423,7 @@ int DolphinApp::OnExit() if (SConfig::GetInstance().m_WiiAutoUnpair) WiimoteReal::UnPair(); #endif - CPluginManager::Shutdown(); + VideoBackend::ClearList(); SConfig::Shutdown(); LogManager::Shutdown(); @@ -438,8 +441,6 @@ void DolphinApp::OnFatalException() // ------------ // Talk to GUI - -// g_VideoInitialize.pSysMessage() goes here void Host_SysMessage(const char *fmt, ...) { va_list list; diff --git a/Source/Core/VideoCommon/Src/BPFunctions.cpp b/Source/Core/VideoCommon/Src/BPFunctions.cpp index a78f12c21aa1..4861ecb83eb4 100644 --- a/Source/Core/VideoCommon/Src/BPFunctions.cpp +++ b/Source/Core/VideoCommon/Src/BPFunctions.cpp @@ -22,6 +22,8 @@ #include "VertexManagerBase.h" #include "VertexShaderManager.h" #include "VideoConfig.h" +#include "HW/Memmap.h" +#include "ConfigManager.h" bool textureChanged[8]; const bool renderFog = false; @@ -202,7 +204,7 @@ bool GetConfig(const int &type) switch (type) { case CONFIG_ISWII: - return g_VideoInitialize.bWii; + return SConfig::GetInstance().m_LocalCoreStartupParameter.bWii; case CONFIG_DISABLEFOG: return g_ActiveConfig.bDisableFog; case CONFIG_SHOWEFBREGIONS: @@ -215,7 +217,7 @@ bool GetConfig(const int &type) u8 *GetPointer(const u32 &address) { - return g_VideoInitialize.pGetMemoryPointer(address); + return Memory::GetPointer(address); } void SetTextureMode(const BPCmd &bp) diff --git a/Source/Core/VideoCommon/Src/CommandProcessor.cpp b/Source/Core/VideoCommon/Src/CommandProcessor.cpp index bae72b3516fd..efc0c35ed934 100644 --- a/Source/Core/VideoCommon/Src/CommandProcessor.cpp +++ b/Source/Core/VideoCommon/Src/CommandProcessor.cpp @@ -78,10 +78,20 @@ #include "ChunkFile.h" #include "CommandProcessor.h" #include "PixelEngine.h" +#include "CoreTiming.h" +#include "ConfigManager.h" +#include "HW/ProcessorInterface.h" +#include "HW/GPFifo.h" +#include "HW/Memmap.h" namespace CommandProcessor { +bool IsOnThread() +{ + return SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread; +} + int et_UpdateInterrupts; @@ -185,7 +195,7 @@ void Init() s_fifoIdleEvent.Init(); - et_UpdateInterrupts = g_VideoInitialize.pRegisterEvent("UpdateInterrupts", UpdateInterrupts_Wrapper); + et_UpdateInterrupts = CoreTiming::RegisterEvent("UpdateInterrupts", UpdateInterrupts_Wrapper); } void Shutdown() @@ -204,7 +214,7 @@ void Read16(u16& _rReturnValue, const u32 _Address) // Here always there is one fifo attached to the GPU - if (g_VideoInitialize.bOnThread) + if (IsOnThread()) { m_CPStatusReg.Breakpoint = fifo.bFF_Breakpoint; m_CPStatusReg.ReadIdle = (fifo.CPReadPointer == fifo.CPWritePointer) || (fifo.CPReadPointer == fifo.CPBreakpoint); @@ -406,7 +416,7 @@ void Write16(const u16 _Value, const u32 _Address) // (mb2) We don't sleep here since it could be a perf issue for super monkey ball (yup only this game IIRC) // Touching that game is a no-go so I don't want to take the risk :p - if (g_VideoInitialize.bOnThread) + if (IsOnThread()) { //ProcessFifoAllDistance(); @@ -437,7 +447,7 @@ void Write16(const u16 _Value, const u32 _Address) // seems invalid or has a bug and hang the game. // Single Core MODE - if (!g_VideoInitialize.bOnThread) + if (!IsOnThread()) { Common::AtomicStore(fifo.bFF_Breakpoint, false); @@ -463,9 +473,9 @@ void Write16(const u16 _Value, const u32 _Address) if(tmpCtrl.GPReadEnable && tmpCtrl.GPLinkEnable) { - *(g_VideoInitialize.Fifo_CPUWritePointer) = fifo.CPWritePointer; - *(g_VideoInitialize.Fifo_CPUBase) = fifo.CPBase; - *(g_VideoInitialize.Fifo_CPUEnd) = fifo.CPEnd; + ProcessorInterface::Fifo_CPUWritePointer = fifo.CPWritePointer; + ProcessorInterface::Fifo_CPUBase = fifo.CPBase; + ProcessorInterface::Fifo_CPUEnd = fifo.CPEnd; } // If overflown happens process the fifo to LoWatemark if (bProcessFifoToLoWatemark) @@ -488,7 +498,7 @@ void Write16(const u16 _Value, const u32 _Address) { UCPClearReg tmpCtrl(_Value); - if (g_VideoInitialize.bOnThread) + if (IsOnThread()) { if (!tmpCtrl.ClearFifoUnderflow && tmpCtrl.ClearFifoOverflow) bProcessFifoToLoWatemark = true; @@ -607,7 +617,7 @@ void Write16(const u16 _Value, const u32 _Address) WARN_LOG(COMMANDPROCESSOR, "(w16) unknown CP reg write %04x @ %08x", _Value, _Address); } - if (!g_VideoInitialize.bOnThread) + if (!IsOnThread()) CatchUpGPU(); ProcessFifoEvents(); } @@ -648,12 +658,12 @@ void STACKALIGN GatherPipeBursted() // if we aren't linked, we don't care about gather pipe data if (!m_CPCtrlReg.GPLinkEnable) { - if (!g_VideoInitialize.bOnThread) + if (!IsOnThread()) CatchUpGPU(); return; } - if (g_VideoInitialize.bOnThread) + if (IsOnThread()) SetOverflowStatusFromGatherPipe(); @@ -667,7 +677,7 @@ void STACKALIGN GatherPipeBursted() - if (!g_VideoInitialize.bOnThread) + if (!IsOnThread()) { CatchUpGPU(); if (!m_CPStatusReg.OverflowHiWatermark && fifo.CPReadWriteDistance >= fifo.CPHiWatermark) @@ -703,17 +713,17 @@ void STACKALIGN GatherPipeBursted() "FIFO is overflown by GatherPipe !\nCPU thread is too fast!"); // check if we are in sync - _assert_msg_(COMMANDPROCESSOR, fifo.CPWritePointer == *(g_VideoInitialize.Fifo_CPUWritePointer), "FIFOs linked but out of sync"); - _assert_msg_(COMMANDPROCESSOR, fifo.CPBase == *(g_VideoInitialize.Fifo_CPUBase), "FIFOs linked but out of sync"); - _assert_msg_(COMMANDPROCESSOR, fifo.CPEnd == *(g_VideoInitialize.Fifo_CPUEnd), "FIFOs linked but out of sync"); + _assert_msg_(COMMANDPROCESSOR, fifo.CPWritePointer == ProcessorInterface::Fifo_CPUWritePointer, "FIFOs linked but out of sync"); + _assert_msg_(COMMANDPROCESSOR, fifo.CPBase == ProcessorInterface::Fifo_CPUBase, "FIFOs linked but out of sync"); + _assert_msg_(COMMANDPROCESSOR, fifo.CPEnd == ProcessorInterface::Fifo_CPUEnd, "FIFOs linked but out of sync"); } // This is only used in single core mode void CatchUpGPU() { - // HyperIris: Memory_GetPtr is an expensive call, call it less, run faster - u8 *ptr = Memory_GetPtr(fifo.CPReadPointer); + // HyperIris: Memory::GetPointer is an expensive call, call it less, run faster + u8 *ptr = Memory::GetPointer(fifo.CPReadPointer); // check if we are able to run this buffer while (fifo.bFF_GPReadEnable && (fifo.CPReadWriteDistance || @@ -767,31 +777,29 @@ void UpdateInterruptsScMode() || (m_CPCtrlReg.FifoUnderflowIntEnable && fifo.bFF_LoWatermark) || (m_CPCtrlReg.FifoOverflowIntEnable && m_CPStatusReg.OverflowHiWatermark); INFO_LOG(COMMANDPROCESSOR, "Fifo Interrupt: %s", (active)? "Asserted" : "Deasserted"); - g_VideoInitialize.pSetInterrupt(INT_CAUSE_CP, active); + ProcessorInterface::SetInterrupt(INT_CAUSE_CP, active); } - - void UpdateInterrupts(u64 userdata) { if (userdata) { interruptSet = true; INFO_LOG(COMMANDPROCESSOR,"Interrupt set"); - g_VideoInitialize.pSetInterrupt(INT_CAUSE_CP, true); + ProcessorInterface::SetInterrupt(INT_CAUSE_CP, true); } else { interruptSet = false; INFO_LOG(COMMANDPROCESSOR,"Interrupt cleared"); - g_VideoInitialize.pSetInterrupt(INT_CAUSE_CP, false); + ProcessorInterface::SetInterrupt(INT_CAUSE_CP, false); } interruptWaiting = false; } void UpdateInterruptsFromVideoPlugin(u64 userdata) { - g_VideoInitialize.pScheduleEvent_Threadsafe(0, et_UpdateInterrupts, userdata); + CoreTiming::ScheduleEvent_Threadsafe(0, et_UpdateInterrupts, userdata); } void SetFifoIdleFromVideoPlugin() @@ -807,8 +815,8 @@ void AbortFrame() { fifo.bFF_GPReadEnable = false; while (CommandProcessor::isFifoBusy) - Common::YieldCPU(); - g_VideoInitialize.pResetGatherPipe(); + Common::YieldCPU(); + GPFifo::ResetGatherPipe(); ResetVideoBuffer(); fifo.CPReadPointer = fifo.CPWritePointer; fifo.CPReadWriteDistance = 0; @@ -876,7 +884,7 @@ void SetStatus() if (interrupt != interruptSet && !interruptWaiting) { u64 userdata = interrupt?1:0; - if (g_VideoInitialize.bOnThread) + if (IsOnThread()) { interruptWaiting = true; CommandProcessor::UpdateInterruptsFromVideoPlugin(userdata); @@ -890,7 +898,7 @@ void SetStatus() void ProcessFifoToLoWatemark() { - if (g_VideoInitialize.bOnThread) + if (IsOnThread()) { while (!CommandProcessor::interruptWaiting && fifo.bFF_GPReadEnable && fifo.CPReadWriteDistance > fifo.CPLoWatermark && !AtBreakpoint()) @@ -901,7 +909,7 @@ void ProcessFifoToLoWatemark() void ProcessFifoAllDistance() { - if (g_VideoInitialize.bOnThread) + if (IsOnThread()) { while (!CommandProcessor::interruptWaiting && fifo.bFF_GPReadEnable && fifo.CPReadWriteDistance && !AtBreakpoint()) @@ -912,8 +920,8 @@ void ProcessFifoAllDistance() void ProcessFifoEvents() { - if (g_VideoInitialize.bOnThread && (interruptWaiting || interruptFinishWaiting || interruptTokenWaiting)) - g_VideoInitialize.pProcessFifoEvents(); + if (IsOnThread() && (interruptWaiting || interruptFinishWaiting || interruptTokenWaiting)) + CoreTiming::ProcessFifoWaitEvents(); } diff --git a/Source/Core/VideoCommon/Src/CommandProcessor.h b/Source/Core/VideoCommon/Src/CommandProcessor.h index cd39d4b0c4d0..78d01ebc06d6 100644 --- a/Source/Core/VideoCommon/Src/CommandProcessor.h +++ b/Source/Core/VideoCommon/Src/CommandProcessor.h @@ -19,7 +19,7 @@ #define _COMMANDPROCESSOR_H #include "Common.h" -#include "pluginspecs_video.h" +#include "VideoBackendBase.h" class PointerWrap; diff --git a/Source/Core/VideoCommon/Src/DLCache.cpp b/Source/Core/VideoCommon/Src/DLCache.cpp index f68fd2625f97..24180da707bd 100644 --- a/Source/Core/VideoCommon/Src/DLCache.cpp +++ b/Source/Core/VideoCommon/Src/DLCache.cpp @@ -26,6 +26,7 @@ #include "DataReader.h" #include "Statistics.h" #include "OpcodeDecoding.h" // For the GX_ constants. +#include "HW/Memmap.h" #include "XFMemory.h" #include "CPMemory.h" @@ -281,9 +282,9 @@ u8 AnalyzeAndRunDisplayList(u32 address, int size, CachedDisplayList *dl) int num_draw_call = 0; u8 result = 0; u8* old_pVideoData = g_pVideoData; - u8* startAddress = Memory_GetPtr(address); + u8* startAddress = Memory::GetPointer(address); - // Avoid the crash if Memory_GetPtr failed .. + // Avoid the crash if Memory::GetPointer failed .. if (startAddress != 0) { g_pVideoData = startAddress; @@ -417,9 +418,9 @@ u8 AnalyzeAndRunDisplayList(u32 address, int size, CachedDisplayList *dl) bool CompileAndRunDisplayList(u32 address, int size, CachedDisplayList *dl) { u8* old_pVideoData = g_pVideoData; - u8* startAddress = Memory_GetPtr(address); + u8* startAddress = Memory::GetPointer(address); - // Avoid the crash if Memory_GetPtr failed .. + // Avoid the crash if Memory::GetPointer failed .. if (startAddress != 0) { g_pVideoData = startAddress; @@ -707,7 +708,7 @@ bool HandleDisplayList(u32 address, u32 size) { case DLCache::DLPASS_COMPILE: // First, check that the hash is the same as the last time. - if (dl.dl_hash != GetHash64(Memory_GetPtr(address), size, 0)) + if (dl.dl_hash != GetHash64(Memory::GetPointer(address), size, 0)) { // PanicAlert("uncachable %08x", address); dl.uncachable = true; @@ -722,7 +723,7 @@ bool HandleDisplayList(u32 address, u32 size) dl.check--; if (dl.check <= 0) { - if (dl.dl_hash != GetHash64(Memory_GetPtr(address), size, 0) || !dl.CheckRegions()) + if (dl.dl_hash != GetHash64(Memory::GetPointer(address), size, 0) || !dl.CheckRegions()) { dl.uncachable = true; dl.check = 60; @@ -760,7 +761,7 @@ bool HandleDisplayList(u32 address, u32 size) DLCache::CachedDisplayList dl; u8 dlvatused = DLCache::AnalyzeAndRunDisplayList(address, size, &dl); - dl.dl_hash = GetHash64(Memory_GetPtr(address), size,0); + dl.dl_hash = GetHash64(Memory::GetPointer(address), size,0); dl.pass = DLCache::DLPASS_COMPILE; dl.check = 1; dl.next_check = 1; diff --git a/Source/Core/VideoCommon/Src/Debugger.cpp b/Source/Core/VideoCommon/Src/Debugger.cpp index 94531e46f044..6ffe8d04ad7e 100644 --- a/Source/Core/VideoCommon/Src/Debugger.cpp +++ b/Source/Core/VideoCommon/Src/Debugger.cpp @@ -31,7 +31,7 @@ volatile bool GFXDebuggerPauseFlag = false; volatile PauseEvent GFXDebuggerToPauseAtNext = NOT_PAUSE; volatile int GFXDebuggerEventToPauseCount = 0; -void UpdateFPSDisplay(const char *text); +//void UpdateFPSDisplay(const char *text); extern NativeVertexFormat *g_nativeVertexFmt; void GFXDebuggerUpdateScreen() @@ -69,7 +69,7 @@ void GFXDebuggerCheckAndPause(bool update) g_pdebugger->OnPause(); while( GFXDebuggerPauseFlag ) { - UpdateFPSDisplay("Paused by Video Debugger"); + g_video_backend->UpdateFPSDisplay("Paused by Video Debugger"); if (update) GFXDebuggerUpdateScreen(); SLEEP(5); diff --git a/Source/Core/VideoCommon/Src/EmuWindow.cpp b/Source/Core/VideoCommon/Src/EmuWindow.cpp index 3f37687f261e..22ec1e78eba4 100644 --- a/Source/Core/VideoCommon/Src/EmuWindow.cpp +++ b/Source/Core/VideoCommon/Src/EmuWindow.cpp @@ -22,7 +22,8 @@ #include "Fifo.h" #include "VertexShaderManager.h" #include "RenderBase.h" - +#include "VideoBackendBase.h" +#include "Core.h" int OSDChoice = 0 , OSDTime = 0, OSDInternalW = 0, OSDInternalH = 0; @@ -223,7 +224,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) return true; case WM_DESTROY: - Shutdown(); + g_video_backend->Shutdown(); break; default: return DefWindowProc(hWnd, iMsg, wParam, lParam); @@ -323,7 +324,7 @@ HWND Create(HWND hParent, HINSTANCE hInstance, const TCHAR *title) // 3. Request window sizes which actually make the client area map to a common resolution HWND Ret; int x=0, y=0, width=640, height=480; - g_VideoInitialize.pGetWindowSize(x, y, width, height); + Core::Callback_VideoGetWindowSize(x, y, width, height); // TODO: Don't show if fullscreen Ret = OpenWindow(hParent, hInstance, width, height, title); diff --git a/Source/Core/VideoCommon/Src/Fifo.cpp b/Source/Core/VideoCommon/Src/Fifo.cpp index 54b411897ef6..c2c50647b61a 100644 --- a/Source/Core/VideoCommon/Src/Fifo.cpp +++ b/Source/Core/VideoCommon/Src/Fifo.cpp @@ -24,6 +24,7 @@ #include "CommandProcessor.h" #include "ChunkFile.h" #include "Fifo.h" +#include "HW/Memmap.h" volatile bool g_bSkipCurrentFrame = false; volatile bool g_EFBAccessRequested = false; @@ -134,16 +135,15 @@ void ResetVideoBuffer() // Description: Main FIFO update loop // Purpose: Keep the Core HW updated about the CPU-GPU distance -void Fifo_EnterLoop(const SVideoInitialize &video_initialize) +void Fifo_EnterLoop() { - fifoStateRun = true; SCPFifoStruct &_fifo = CommandProcessor::fifo; s32 distToSend; while (fifoStateRun) { - video_initialize.pPeekMessages(); + g_video_backend->PeekMessages(); VideoFifo_CheckAsyncRequest(); @@ -164,7 +164,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) // Create pointer to video data and send it to the VideoPlugin u32 readPtr = _fifo.CPReadPointer; - u8 *uData = video_initialize.pGetMemoryPointer(readPtr); + u8 *uData = Memory::GetPointer(readPtr); distToSend = 32; @@ -204,7 +204,7 @@ void Fifo_EnterLoop(const SVideoInitialize &video_initialize) // While the emu is paused, we still handle async request such as Savestates then sleep. while (!EmuRunning) { - video_initialize.pPeekMessages(); + g_video_backend->PeekMessages(); VideoFifo_CheckAsyncRequest(); Common::SleepCurrentThread(10); } diff --git a/Source/Core/VideoCommon/Src/Fifo.h b/Source/Core/VideoCommon/Src/Fifo.h index 3789406af6a6..b60cb892b876 100644 --- a/Source/Core/VideoCommon/Src/Fifo.h +++ b/Source/Core/VideoCommon/Src/Fifo.h @@ -18,8 +18,8 @@ #ifndef _FIFO_H #define _FIFO_H -#include "pluginspecs_video.h" #include "Common.h" +#include "VideoBackendBase.h" class PointerWrap; @@ -34,7 +34,7 @@ void Fifo_Shutdown(); void Fifo_SendFifoData(u8* _uData, u32 len); // These two are for dual core mode only. -void Fifo_EnterLoop(const SVideoInitialize &video_initialize); +void Fifo_EnterLoop(); void Fifo_ExitLoop(); void Fifo_ExitLoopNonBlocking(); void Fifo_RunLoop(bool run); diff --git a/Source/Core/VideoCommon/Src/MainBase.cpp b/Source/Core/VideoCommon/Src/MainBase.cpp index 8006d694a202..762ffcb1578d 100644 --- a/Source/Core/VideoCommon/Src/MainBase.cpp +++ b/Source/Core/VideoCommon/Src/MainBase.cpp @@ -12,6 +12,8 @@ #include "Fifo.h" #include "BPStructs.h" #include "OnScreenDisplay.h" +#include "VideoBackendBase.h" +#include "ConfigManager.h" bool s_PluginInitialized = false; @@ -37,25 +39,24 @@ static struct static u32 s_AccessEFBResult = 0; - -void EmuStateChange(PLUGIN_EMUSTATE newState) +void VideoBackendHLE::EmuStateChange(PLUGIN_EMUSTATE newState) { Fifo_RunLoop((newState == PLUGIN_EMUSTATE_PLAY) ? true : false); } // Enter and exit the video loop -void Video_EnterLoop() +void VideoBackendHLE::Video_EnterLoop() { - Fifo_EnterLoop(g_VideoInitialize); + Fifo_EnterLoop(); } -void Video_ExitLoop() +void VideoBackendHLE::Video_ExitLoop() { Fifo_ExitLoop(); s_FifoShuttingDown = true; } -void Video_SetRendering(bool bEnabled) +void VideoBackendHLE::Video_SetRendering(bool bEnabled) { Fifo_SetRendering(bEnabled); } @@ -93,11 +94,11 @@ void VideoFifo_CheckSwapRequestAt(u32 xfbAddr, u32 fbWidth, u32 fbHeight) } // Run from the CPU thread (from VideoInterface.cpp) -void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) +void VideoBackendHLE::Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) { if (s_PluginInitialized && g_ActiveConfig.bUseXFB) { - if (!g_VideoInitialize.bOnThread) + if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread) VideoFifo_CheckSwapRequest(); s_beginFieldArgs.xfbAddr = xfbAddr; s_beginFieldArgs.field = field; @@ -107,7 +108,7 @@ void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) } // Run from the CPU thread (from VideoInterface.cpp) -void Video_EndField() +void VideoBackendHLE::Video_EndField() { if (s_PluginInitialized) { @@ -115,15 +116,16 @@ void Video_EndField() } } -void Video_AddMessage(const char* pstr, u32 milliseconds) +void VideoBackendHLE::Video_AddMessage(const char* pstr, u32 milliseconds) { OSD::AddMessage(pstr, milliseconds); } // Screenshot -void Video_Screenshot(const char *_szFilename) +bool VideoBackendHLE::Video_Screenshot(const char *_szFilename) { Renderer::SetScreenshot(_szFilename); + return true; } void VideoFifo_CheckEFBAccess() @@ -136,7 +138,7 @@ void VideoFifo_CheckEFBAccess() } } -u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData) +u32 VideoBackendHLE::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData) { if (s_PluginInitialized) { @@ -147,7 +149,7 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData) Common::AtomicStoreRelease(s_efbAccessRequested, TRUE); - if (g_VideoInitialize.bOnThread) + if (SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread) { while (Common::AtomicLoadAcquire(s_efbAccessRequested) && !s_FifoShuttingDown) //Common::SleepCurrentThread(1); @@ -196,12 +198,12 @@ static void check_DoState() { } // Run from the CPU thread -void DoState(unsigned char **ptr, int mode) +void VideoBackendHLE::DoState(PointerWrap& p) { - s_doStateArgs.ptr = ptr; - s_doStateArgs.mode = mode; + s_doStateArgs.ptr = p.ptr; + s_doStateArgs.mode = p.mode; Common::AtomicStoreRelease(s_doStateRequested, TRUE); - if (g_VideoInitialize.bOnThread) + if (SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread) { while (Common::AtomicLoadAcquire(s_doStateRequested) && !s_FifoShuttingDown) //Common::SleepCurrentThread(1); @@ -218,47 +220,22 @@ void VideoFifo_CheckAsyncRequest() check_DoState(); } -void Video_CommandProcessorRead16(u16& _rReturnValue, const u32 _Address) -{ - CommandProcessor::Read16(_rReturnValue, _Address); -} - -void Video_CommandProcessorWrite16(const u16 _Data, const u32 _Address) -{ - CommandProcessor::Write16(_Data, _Address); -} - -void Video_PixelEngineRead16(u16& _rReturnValue, const u32 _Address) -{ - PixelEngine::Read16(_rReturnValue, _Address); -} - -void Video_PixelEngineWrite16(const u16 _Data, const u32 _Address) -{ - PixelEngine::Write16(_Data, _Address); -} - -void Video_PixelEngineWrite32(const u32 _Data, const u32 _Address) -{ - PixelEngine::Write32(_Data, _Address); -} - -void Video_GatherPipeBursted(void) +void VideoBackend::Video_GatherPipeBursted() { CommandProcessor::GatherPipeBursted(); } -void Video_WaitForFrameFinish(void) +void VideoBackendHLE::Video_WaitForFrameFinish() { CommandProcessor::WaitForFrameFinish(); } -bool Video_IsFifoBusy(void) +bool VideoBackendHLE::Video_IsFifoBusy() { return CommandProcessor::isFifoBusy; } -void Video_AbortFrame(void) +void VideoBackendHLE::Video_AbortFrame() { CommandProcessor::AbortFrame(); } diff --git a/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp b/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp index 8641e0db73a5..14c8e9417313 100644 --- a/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp +++ b/Source/Core/VideoCommon/Src/OpcodeDecoding.cpp @@ -30,6 +30,9 @@ #include "OpcodeDecoding.h" #include "CommandProcessor.h" #include "CPUDetect.h" +#include "Core.h" +#include "Host.h" +#include "HW/Memmap.h" #include "VertexLoaderManager.h" @@ -95,9 +98,9 @@ static void Decode(); void InterpretDisplayList(u32 address, u32 size) { u8* old_pVideoData = g_pVideoData; - u8* startAddress = Memory_GetPtr(address); + u8* startAddress = Memory::GetPointer(address); - // Avoid the crash if Memory_GetPtr failed .. + // Avoid the crash if Memory::GetPointer failed .. if (startAddress != 0) { g_pVideoData = startAddress; @@ -201,16 +204,16 @@ bool FifoCommandRunnable() else { // TODO(Omega): Maybe dump FIFO to file on this error - char szTemp[1024]; - sprintf(szTemp, "GFX FIFO: Unknown Opcode (0x%x).\n" + char szTemp[1024]; + sprintf(szTemp, "GFX FIFO: Unknown Opcode (0x%x).\n" "This means one of the following:\n" "* The emulated GPU got desynced, disabling dual core can help\n" "* Command stream corrupted by some spurious memory bug\n" "* This really is an unknown opcode (unlikely)\n" "* Some other sort of bug\n\n" "Dolphin will now likely crash or hang. Enjoy." , cmd_byte); - g_VideoInitialize.pSysMessage(szTemp); - g_VideoInitialize.pLog(szTemp, TRUE); + Host_SysMessage(szTemp); + Core::Callback_VideoLog(szTemp, TRUE); { SCPFifoStruct &fifo = CommandProcessor::fifo; @@ -234,8 +237,8 @@ bool FifoCommandRunnable() ,fifo.bFF_BPEnable ? "true" : "false" ,fifo.bFF_BPInt ? "true" : "false" ,fifo.bFF_Breakpoint ? "true" : "false"); - g_VideoInitialize.pSysMessage(szTmp); - g_VideoInitialize.pLog(szTmp, TRUE); + Host_SysMessage(szTmp); + Core::Callback_VideoLog(szTmp, TRUE); } } break; diff --git a/Source/Core/VideoCommon/Src/PixelEngine.cpp b/Source/Core/VideoCommon/Src/PixelEngine.cpp index bdf190ff6091..a5584d581753 100644 --- a/Source/Core/VideoCommon/Src/PixelEngine.cpp +++ b/Source/Core/VideoCommon/Src/PixelEngine.cpp @@ -24,9 +24,12 @@ #include "VideoCommon.h" #include "ChunkFile.h" #include "Atomic.h" +#include "CoreTiming.h" +#include "ConfigManager.h" #include "PixelEngine.h" #include "CommandProcessor.h" +#include "HW/ProcessorInterface.h" namespace PixelEngine { @@ -151,8 +154,8 @@ void Init() { m_Control.Hex = 0; - et_SetTokenOnMainThread = g_VideoInitialize.pRegisterEvent("SetToken", SetToken_OnMainThread); - et_SetFinishOnMainThread = g_VideoInitialize.pRegisterEvent("SetFinish", SetFinish_OnMainThread); + et_SetTokenOnMainThread = CoreTiming::RegisterEvent("SetToken", SetToken_OnMainThread); + et_SetFinishOnMainThread = CoreTiming::RegisterEvent("SetFinish", SetFinish_OnMainThread); bbox[0] = 0x80; bbox[1] = 0xA0; @@ -298,7 +301,7 @@ void Write32(const u32 _iValue, const u32 _iAddress) bool AllowIdleSkipping() { - return !g_VideoInitialize.bOnThread || (!m_Control.PETokenEnable && !m_Control.PEFinishEnable); + return !SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread || (!m_Control.PETokenEnable && !m_Control.PEFinishEnable); } void UpdateInterrupts() @@ -314,7 +317,7 @@ void UpdateTokenInterrupt(bool active) { if(interruptSetToken != active) { - g_VideoInitialize.pSetInterrupt(INT_CAUSE_PE_TOKEN, active); + ProcessorInterface::SetInterrupt(INT_CAUSE_PE_TOKEN, active); interruptSetToken = active; } } @@ -324,7 +327,7 @@ void UpdateFinishInterrupt(bool active) if(interruptSetFinish != active) { - g_VideoInitialize.pSetInterrupt(INT_CAUSE_PE_FINISH, active); + ProcessorInterface::SetInterrupt(INT_CAUSE_PE_FINISH, active); interruptSetFinish = active; } } @@ -366,8 +369,7 @@ void SetToken(const u16 _token, const int _bSetTokenAcknowledge) CommandProcessor::IncrementGPWDToken(); // for DC watchdog hack since PEToken seems to be a frame-finish too Common::AtomicStore(*(volatile u32*)&CommandProcessor::fifo.PEToken, _token); CommandProcessor::interruptTokenWaiting = true; - g_VideoInitialize.pScheduleEvent_Threadsafe( - 0, et_SetTokenOnMainThread, _token | (_bSetTokenAcknowledge << 16)); + CoreTiming::ScheduleEvent_Threadsafe(0, et_SetTokenOnMainThread, _token | (_bSetTokenAcknowledge << 16)); } else // set token value { @@ -386,8 +388,7 @@ void SetFinish() { CommandProcessor::IncrementGPWDToken(); // for DC watchdog hack CommandProcessor::interruptFinishWaiting = true; - g_VideoInitialize.pScheduleEvent_Threadsafe( - 0, et_SetFinishOnMainThread, 0); + CoreTiming::ScheduleEvent_Threadsafe(0, et_SetFinishOnMainThread, 0); INFO_LOG(PIXELENGINE, "VIDEO Set Finish"); } @@ -401,9 +402,10 @@ void ResetSetFinish() UpdateFinishInterrupt(false); g_bSignalFinishInterrupt = false; - }else + } + else { - g_VideoInitialize.pRemoveEvent(et_SetFinishOnMainThread); + CoreTiming::RemoveEvent(et_SetFinishOnMainThread); } CommandProcessor::interruptFinishWaiting = false; } @@ -415,9 +417,10 @@ void ResetSetToken() UpdateTokenInterrupt(false); g_bSignalTokenInterrupt = false; - }else + } + else { - g_VideoInitialize.pRemoveEvent(et_SetTokenOnMainThread); + CoreTiming::RemoveEvent(et_SetTokenOnMainThread); } CommandProcessor::interruptTokenWaiting = false; } diff --git a/Source/Core/VideoCommon/Src/PixelShaderManager.cpp b/Source/Core/VideoCommon/Src/PixelShaderManager.cpp index 96ba2cb3f2b3..1618a3bdabeb 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderManager.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderManager.cpp @@ -22,7 +22,9 @@ #include "PixelShaderManager.h" #include "VideoCommon.h" #include "VideoConfig.h" + #include "RenderBase.h" + static float GC_ALIGNED16(s_fMaterials[16]); static int s_nColorsChanged[2]; // 0 - regular colors, 1 - k colors static int s_nIndTexMtxChanged; @@ -43,6 +45,21 @@ static u32 lastTexDims[8]; // width | height << 16 | wrap_s << 28 | wrap_t << 30 static u32 lastZBias; static int nMaterialsChanged; +inline void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) +{ + g_renderer->SetPSConstant4f(const_number, f1, f2, f3, f4); +} + +inline void SetPSConstant4fv(unsigned int const_number, const float *f) +{ + g_renderer->SetPSConstant4fv(const_number, f); +} + +inline void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f) +{ + g_renderer->SetMultiPSConstant4fv(const_number, count, f); +} + void PixelShaderManager::Init() { lastAlpha = 0; @@ -97,7 +114,7 @@ void PixelShaderManager::SetConstants() if (s_bAlphaChanged) { - SetPSConstant4f(C_ALPHA, (lastAlpha&0xff)/255.0f, ((lastAlpha>>8)&0xff)/255.0f, 0, ((lastAlpha>>16)&0xff)/255.0f); + SetPSConstant4f(C_ALPHA, (lastAlpha&0xff)/255.0f, ((lastAlpha>>8)&0xff)/255.0f, 0, ((lastAlpha>>16)&0xff)/255.0f); s_bAlphaChanged = false; } @@ -126,7 +143,7 @@ void PixelShaderManager::SetConstants() if (s_bZBiasChanged || s_bDepthRangeChanged) { //ERROR_LOG("pixel=%x,%x, bias=%x\n", bpmem.zcontrol.pixel_format, bpmem.ztex2.type, lastZBias); - SetPSConstant4f(C_ZBIAS+1, lastDepthRange[0] / 16777216.0f, lastDepthRange[1] / 16777216.0f, 0, (float)(lastZBias)/16777215.0f); + SetPSConstant4f(C_ZBIAS+1, lastDepthRange[0] / 16777216.0f, lastDepthRange[1] / 16777216.0f, 0, (float)(lastZBias)/16777215.0f); s_bZBiasChanged = s_bDepthRangeChanged = false; } @@ -144,7 +161,7 @@ void PixelShaderManager::SetConstants() f[2 * i + 1] = bpmem.texscale[0].getScaleT(i & 1); PRIM_LOG("tex indscale%d: %f %f\n", i, f[2 * i], f[2 * i + 1]); } - SetPSConstant4fv(C_INDTEXSCALE, f); + SetPSConstant4fv(C_INDTEXSCALE, f); } if (s_nIndTexScaleChanged & 0x0c) { @@ -153,7 +170,7 @@ void PixelShaderManager::SetConstants() f[2 * i + 1] = bpmem.texscale[1].getScaleT(i & 1); PRIM_LOG("tex indscale%d: %f %f\n", i, f[2 * i], f[2 * i + 1]); } - SetPSConstant4fv(C_INDTEXSCALE+1, &f[4]); + SetPSConstant4fv(C_INDTEXSCALE+1, &f[4]); } s_nIndTexScaleChanged = 0; @@ -173,7 +190,7 @@ void PixelShaderManager::SetConstants() // xyz - static matrix // TODO w - dynamic matrix scale / 256...... somehow / 4 works better // rev 2972 - now using / 256.... verify that this works - SetPSConstant4f(C_INDTEXMTX + 2 * i, + SetPSConstant4f(C_INDTEXMTX + 2 * i, bpmem.indmtx[i].col0.ma * fscale, bpmem.indmtx[i].col1.mc * fscale, bpmem.indmtx[i].col2.me * fscale, @@ -195,8 +212,8 @@ void PixelShaderManager::SetConstants() if (s_bFogColorChanged) { - SetPSConstant4f(C_FOG, bpmem.fog.color.r / 255.0f, bpmem.fog.color.g / 255.0f, bpmem.fog.color.b / 255.0f, 0); - s_bFogColorChanged = false; + SetPSConstant4f(C_FOG, bpmem.fog.color.r / 255.0f, bpmem.fog.color.g / 255.0f, bpmem.fog.color.b / 255.0f, 0); + s_bFogColorChanged = false; } if (s_bFogParamChanged) diff --git a/Source/Core/VideoCommon/Src/PixelShaderManager.h b/Source/Core/VideoCommon/Src/PixelShaderManager.h index f3428eda6f9b..51e4705925ee 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderManager.h +++ b/Source/Core/VideoCommon/Src/PixelShaderManager.h @@ -22,10 +22,6 @@ #include "XFMemory.h" #include "PixelShaderGen.h" -void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4); -void SetPSConstant4fv(unsigned int const_number, const float *f); -void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f); - // The non-API dependent parts. class PixelShaderManager { diff --git a/Source/Core/VideoCommon/Src/RenderBase.cpp b/Source/Core/VideoCommon/Src/RenderBase.cpp index 4d584f27110d..7b99d2f6b2a5 100644 --- a/Source/Core/VideoCommon/Src/RenderBase.cpp +++ b/Source/Core/VideoCommon/Src/RenderBase.cpp @@ -42,9 +42,6 @@ int frameCount; //int OSDChoice, OSDTime, OSDInternalW, OSDInternalH; -SVideoInitialize g_VideoInitialize; -PLUGIN_GLOBALS* globals; - Renderer *g_renderer; bool s_bLastFrameDumped = false; diff --git a/Source/Core/VideoCommon/Src/RenderBase.h b/Source/Core/VideoCommon/Src/RenderBase.h index 27727ab7de0d..6085581475cb 100644 --- a/Source/Core/VideoCommon/Src/RenderBase.h +++ b/Source/Core/VideoCommon/Src/RenderBase.h @@ -31,7 +31,6 @@ #include "VideoCommon.h" #include "Thread.h" #include "MathUtil.h" -#include "pluginspecs_video.h" #include "NativeVertexFormat.h" #include "FramebufferManagerBase.h" #include "BPMemory.h" @@ -43,8 +42,6 @@ extern int frameCount; extern int OSDChoice, OSDTime; extern bool s_bLastFrameDumped; -extern SVideoInitialize g_VideoInitialize; -extern PLUGIN_GLOBALS* globals; // Renderer really isn't a very good name for this class - it's more like "Misc". // The long term goal is to get rid of this class and replace it with others that make @@ -132,6 +129,17 @@ class Renderer static unsigned int GetPrevPixelFormat() { return prev_efb_format; } static void StorePixelFormat(unsigned int new_format) { prev_efb_format = new_format; } + // TODO: doesn't belong here + virtual void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) = 0; + virtual void SetPSConstant4fv(unsigned int const_number, const float *f) = 0; + virtual void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f) = 0; + + // TODO: doesn't belong here + virtual void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) = 0; + virtual void SetVSConstant4fv(unsigned int const_number, const float *f) = 0; + virtual void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f) = 0; + virtual void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f) = 0; + protected: static Common::CriticalSection s_criticalScreenshot; diff --git a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp index a0ff82df8241..eb6c4c853970 100644 --- a/Source/Core/VideoCommon/Src/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/Src/TextureCacheBase.cpp @@ -11,6 +11,8 @@ #include "TextureCacheBase.h" #include "Debugger.h" +#include "ConfigManager.h" +#include "HW/Memmap.h" // ugly extern int frameCount; @@ -33,20 +35,17 @@ TextureCache::TCacheEntryBase::~TCacheEntryBase() if (!isRenderTarget && !g_ActiveConfig.bSafeTextureCache) { - u32 *const ptr = (u32*)g_VideoInitialize.pGetMemoryPointer(addr); + u32 *const ptr = (u32*)Memory::GetPointer(addr); if (ptr && *ptr == hash) *ptr = oldpixel; } } -// TODO: uglyness -extern PLUGIN_GLOBALS *globals; - TextureCache::TextureCache() { temp = (u8*)AllocateMemoryPages(TEMP_SIZE); TexDecoder_SetTexFmtOverlayOptions(g_ActiveConfig.bTexFmtOverlayEnable, g_ActiveConfig.bTexFmtOverlayCenter); - HiresTextures::Init(globals->unique_id); + HiresTextures::Init(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); } void TextureCache::Invalidate(bool shutdown) @@ -164,7 +163,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage, if (0 == address) return NULL; - u8* ptr = g_VideoInitialize.pGetMemoryPointer(address); + u8* ptr = Memory::GetPointer(address); // TexelSizeInNibbles(format)*width*height/16; const unsigned int bsw = TexDecoder_GetBlockWidthInTexels(texformat) - 1; @@ -288,7 +287,7 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage, unsigned int newWidth = width; unsigned int newHeight = height; - sprintf(texPathTemp, "%s_%08llx_%i", globals->unique_id, texHash, texformat); + sprintf(texPathTemp, "%s_%08llx_%i", SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), texHash, texformat); pcfmt = HiresTextures::GetHiresTex(texPathTemp, &newWidth, &newHeight, texformat, temp); if (pcfmt != PC_TEX_FMT_NONE) @@ -385,11 +384,11 @@ TextureCache::TCacheEntryBase* TextureCache::Load(unsigned int stage, char szDir[MAX_PATH]; // make sure that the directory exists - sprintf(szDir, "%s%s", File::GetUserPath(D_DUMPTEXTURES_IDX), globals->unique_id); + sprintf(szDir, "%s%s", File::GetUserPath(D_DUMPTEXTURES_IDX), SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); if (false == File::Exists(szDir) || false == File::IsDirectory(szDir)) File::CreateDir(szDir); - sprintf(szTemp, "%s/%s_%08llx_%i.png", szDir, globals->unique_id, texHash, texformat); + sprintf(szTemp, "%s/%s_%08llx_%i.png", szDir, SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str(), texHash, texformat); if (false == File::Exists(szTemp)) entry->Save(szTemp); diff --git a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp index c2aff1ab1e67..c24a11b180f5 100644 --- a/Source/Core/VideoCommon/Src/TextureConversionShader.cpp +++ b/Source/Core/VideoCommon/Src/TextureConversionShader.cpp @@ -25,6 +25,7 @@ #include "PixelShaderManager.h" #include "PixelShaderGen.h" #include "BPMemory.h" +#include "RenderBase.h" #define WRITE p+=sprintf @@ -874,8 +875,8 @@ const char *GenerateEncodingShader(u32 format,API_TYPE ApiType) void SetShaderParameters(float width, float height, float offsetX, float offsetY, float widthStride, float heightStride,float buffW,float buffH) { - SetPSConstant4f(C_COLORMATRIX, widthStride, heightStride, buffW, buffH); - SetPSConstant4f(C_COLORMATRIX + 1, width, (height - 1), offsetX, offsetY); + g_renderer->SetPSConstant4f(C_COLORMATRIX, widthStride, heightStride, buffW, buffH); + g_renderer->SetPSConstant4f(C_COLORMATRIX + 1, width, (height - 1), offsetX, offsetY); } } // namespace diff --git a/Source/Core/VideoCommon/Src/VertexLoader.cpp b/Source/Core/VideoCommon/Src/VertexLoader.cpp index 01f58ed4d418..aa7ff2ec4c70 100644 --- a/Source/Core/VideoCommon/Src/VertexLoader.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoader.cpp @@ -25,6 +25,7 @@ #include "x64Emitter.h" #include "ABI.h" #include "PixelEngine.h" +#include "Host.h" #include "LookUpTables.h" #include "Statistics.h" @@ -302,7 +303,7 @@ void VertexLoader::CompileVertexTranslator() { char temp[256]; sprintf(temp,"%i %i %i %i", m_VtxDesc.Normal, m_VtxAttr.NormalFormat, m_VtxAttr.NormalElements, m_VtxAttr.NormalIndex3); - g_VideoInitialize.pSysMessage("VertexLoader_Normal::GetFunction returned zero!"); + Host_SysMessage("VertexLoader_Normal::GetFunction returned zero!"); } WriteCall(pFunc); diff --git a/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp b/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp index c03f0d94fd0b..564892cb9874 100644 --- a/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp +++ b/Source/Core/VideoCommon/Src/VertexLoaderManager.cpp @@ -32,6 +32,7 @@ using __gnu_cxx::hash_map; #include "VertexShaderManager.h" #include "VertexLoader.h" #include "VertexLoaderManager.h" +#include "HW/Memmap.h" static int s_attr_dirty; // bitfield @@ -204,7 +205,7 @@ void LoadCPReg(u32 sub_cmd, u32 value) // Pointers to vertex arrays in GC RAM case 0xA0: arraybases[sub_cmd & 0xF] = value; - cached_arraybases[sub_cmd & 0xF] = Memory_GetPtr(value); + cached_arraybases[sub_cmd & 0xF] = Memory::GetPointer(value); break; case 0xB0: @@ -217,6 +218,6 @@ void RecomputeCachedArraybases() { for (int i = 0; i < 16; i++) { - cached_arraybases[i] = Memory_GetPtr(arraybases[i]); + cached_arraybases[i] = Memory::GetPointer(arraybases[i]); } } diff --git a/Source/Core/VideoCommon/Src/VertexShaderManager.cpp b/Source/Core/VideoCommon/Src/VertexShaderManager.cpp index f735ead5c879..cd42ad6c17af 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderManager.cpp +++ b/Source/Core/VideoCommon/Src/VertexShaderManager.cpp @@ -32,6 +32,8 @@ #include "VideoCommon.h" #include "VertexManagerBase.h" +#include "RenderBase.h" + static float GC_ALIGNED16(s_fMaterials[16]); float GC_ALIGNED16(g_fProjectionMatrix[16]); @@ -50,6 +52,26 @@ static float s_fViewRotation[2]; void UpdateViewport(); +inline void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) +{ + g_renderer->SetVSConstant4f(const_number, f1, f2, f3, f4); +} + +inline void SetVSConstant4fv(unsigned int const_number, const float *f) +{ + g_renderer->SetVSConstant4fv(const_number, f); +} + +inline void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f) +{ + g_renderer->SetMultiVSConstant3fv(const_number, count, f); +} + +inline void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f) +{ + g_renderer->SetMultiVSConstant4fv(const_number, count, f); +} + namespace { // Control Variables diff --git a/Source/Core/VideoCommon/Src/VertexShaderManager.h b/Source/Core/VideoCommon/Src/VertexShaderManager.h index 5dc08fdf369a..32fa555cdbd6 100644 --- a/Source/Core/VideoCommon/Src/VertexShaderManager.h +++ b/Source/Core/VideoCommon/Src/VertexShaderManager.h @@ -55,10 +55,4 @@ class VertexShaderManager static void ResetView(); }; -void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4); -void SetVSConstant4fv(unsigned int const_number, const float *f); -void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f); -void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f); - - #endif // _VERTEXSHADERMANAGER_H diff --git a/Source/Core/VideoCommon/Src/VideoCommon.h b/Source/Core/VideoCommon/Src/VideoCommon.h index 0b2987417887..67c89465a0a9 100644 --- a/Source/Core/VideoCommon/Src/VideoCommon.h +++ b/Source/Core/VideoCommon/Src/VideoCommon.h @@ -20,7 +20,7 @@ #include "Common.h" #include "MathUtil.h" -#include "pluginspecs_video.h" +#include "VideoBackendBase.h" #if defined(_MSC_VER) && !defined(__x86_64__) && !defined(_M_X64) void * memcpy_amd(void *dest, const void *src, size_t n); @@ -57,44 +57,6 @@ enum // Do testing to figure out if the speed hit is bad? // #define BBOX_SUPPORT -extern SVideoInitialize g_VideoInitialize; - -inline u8 *Memory_GetPtr(u32 _uAddress) -{ - return g_VideoInitialize.pGetMemoryPointer(_uAddress); -} - -inline u8 Memory_Read_U8(u32 _uAddress) -{ - return *(u8*)g_VideoInitialize.pGetMemoryPointer(_uAddress); -} - -inline u16 Memory_Read_U16(u32 _uAddress) -{ - return Common::swap16(*(u16*)g_VideoInitialize.pGetMemoryPointer(_uAddress)); -} - -inline u32 Memory_Read_U32(u32 _uAddress) -{ - return Common::swap32(*(u32*)g_VideoInitialize.pGetMemoryPointer(_uAddress)); -} - -inline u8* Memory_Read_U8_Ptr(u32 _uAddress) -{ - return (u8*)g_VideoInitialize.pGetMemoryPointer(_uAddress); -} - -inline u16* Memory_Read_U16_Unswapped_Ptr(u32 _uAddress) -{ - return (u16*)g_VideoInitialize.pGetMemoryPointer(_uAddress); -} - -inline u32* Memory_Read_U32_Unswapped_Ptr(u32 _uAddress) -{ - return (u32*)g_VideoInitialize.pGetMemoryPointer(_uAddress); -} - - // Logging // ---------- void HandleGLError(); diff --git a/Source/Core/VideoCommon/Src/VideoConfig.cpp b/Source/Core/VideoCommon/Src/VideoConfig.cpp index 424732c8df3d..2bad82836ed1 100644 --- a/Source/Core/VideoCommon/Src/VideoConfig.cpp +++ b/Source/Core/VideoCommon/Src/VideoConfig.cpp @@ -243,6 +243,9 @@ void VideoConfig::Save(const char *ini_file) iniFile.Save(ini_file); } +// TODO: remove +extern bool g_aspect_wide; + // TODO: Figure out a better place for this function. void ComputeDrawRectangle(int backbuffer_width, int backbuffer_height, bool flip, TargetRectangle *rc) { @@ -257,7 +260,7 @@ void ComputeDrawRectangle(int backbuffer_width, int backbuffer_height, bool flip // Handle aspect ratio. // Default to auto. - bool use16_9 = g_VideoInitialize.bAutoAspectIs16_9; + bool use16_9 = g_aspect_wide; // Update aspect ratio hack values // Won't take effect until next frame diff --git a/Source/Core/VideoCommon/Src/XFStructs.cpp b/Source/Core/VideoCommon/Src/XFStructs.cpp index 0b93599967bb..21f8ba0bdaa4 100644 --- a/Source/Core/VideoCommon/Src/XFStructs.cpp +++ b/Source/Core/VideoCommon/Src/XFStructs.cpp @@ -22,6 +22,7 @@ #include "VertexManagerBase.h" #include "VertexShaderManager.h" #include "PixelShaderManager.h" +#include "HW/Memmap.h" // LoadXFReg 0x10 void LoadXFReg(u32 transferSize, u32 baseAddress, u32 *pData) @@ -224,5 +225,5 @@ void LoadIndexedXF(u32 val, int array) //PRIM_LOG("xfmem iwrite: 0x%x-0x%x\n", address, address+size); for (int i = 0; i < size; i++) - xfmem[address + i] = Memory_Read_U32(arraybases[array] + arraystrides[array] * index + i * 4); + xfmem[address + i] = Memory::Read_U32(arraybases[array] + arraystrides[array] * index + i * 4); } diff --git a/Source/Core/VideoCommon/VideoCommon.vcxproj b/Source/Core/VideoCommon/VideoCommon.vcxproj index 8f526dca82d8..72ca233e44f8 100644 --- a/Source/Core/VideoCommon/VideoCommon.vcxproj +++ b/Source/Core/VideoCommon/VideoCommon.vcxproj @@ -127,7 +127,7 @@ Level3 Disabled - ..\Common\Src;..\..\PluginSpecs;..\..\..\Externals\SOIL;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) + ..\Common\Src;..\Core\Src;..\..\PluginSpecs;..\..\..\Externals\SOIL;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreadedDebug @@ -142,7 +142,7 @@ Level3 Disabled - ..\Common\Src;..\..\PluginSpecs;..\..\..\Externals\SOIL;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) + ..\Common\Src;..\Core\Src;..\..\PluginSpecs;..\..\..\Externals\SOIL;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreadedDebug @@ -159,7 +159,7 @@ MaxSpeed true true - ..\Common\Src;..\..\PluginSpecs;..\..\..\Externals\SOIL;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) + ..\Common\Src;..\Core\Src;..\..\PluginSpecs;..\..\..\Externals\SOIL;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded @@ -178,7 +178,7 @@ MaxSpeed true true - ..\Common\Src;..\..\PluginSpecs;..\..\..\Externals\SOIL;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) + ..\Common\Src;..\Core\Src;..\..\PluginSpecs;..\..\..\Externals\SOIL;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) DEBUGFAST;_SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded @@ -197,7 +197,7 @@ MaxSpeed true true - ..\Common\Src;..\..\PluginSpecs;..\..\..\Externals\SOIL;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) + ..\Common\Src;..\Core\Src;..\..\PluginSpecs;..\..\..\Externals\SOIL;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded @@ -216,7 +216,7 @@ MaxSpeed true true - ..\Common\Src;..\..\PluginSpecs;..\..\..\Externals\SOIL;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) + ..\Common\Src;..\Core\Src;..\..\PluginSpecs;..\..\..\Externals\SOIL;..\..\..\Externals\CLRun\include;%(AdditionalIncludeDirectories) DEBUGFAST;_SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded @@ -350,4 +350,4 @@ - + \ No newline at end of file diff --git a/Source/Core/VideoUICommon/Src/DebuggerPanel.cpp b/Source/Core/VideoUICommon/Src/DebuggerPanel.cpp index 74d1488a500f..45d6fbbe2479 100644 --- a/Source/Core/VideoUICommon/Src/DebuggerPanel.cpp +++ b/Source/Core/VideoUICommon/Src/DebuggerPanel.cpp @@ -19,6 +19,7 @@ #include "IniFile.h" #include "DebuggerPanel.h" #include "FileUtil.h" +#include "../../Core/Src/ConfigManager.h" #include "VideoConfig.h" #include "TextureCacheBase.h" @@ -26,8 +27,6 @@ #include "VertexShaderGen.h" #include "NativeVertexFormat.h" -extern PLUGIN_GLOBALS* globals; - BEGIN_EVENT_TABLE(GFXDebuggerPanel, wxPanel) EVT_CLOSE(GFXDebuggerPanel::OnClose) EVT_BUTTON(ID_PAUSE,GFXDebuggerPanel::OnPauseButton) @@ -249,7 +248,7 @@ void GFXDebuggerPanel::OnPauseAtNextFrameButton(wxCommandEvent& event) void GFXDebuggerPanel::OnDumpButton(wxCommandEvent& event) { char dump_path[MAX_PATH]; - sprintf(dump_path, "%sDebug/%s/", File::GetUserPath(D_DUMP_IDX), globals->unique_id); + sprintf(dump_path, "%sDebug/%s/", File::GetUserPath(D_DUMP_IDX), SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); if (!File::CreateFullPath(dump_path)) return; diff --git a/Source/Dolphin.sln b/Source/Dolphin.sln index d87057309b67..e1e36c49a8cf 100644 --- a/Source/Dolphin.sln +++ b/Source/Dolphin.sln @@ -14,7 +14,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Core", "Core\Core\Core.vcpr {B7F1A9FB-BEA8-416E-9460-AE35A6A5165C} = {B7F1A9FB-BEA8-416E-9460-AE35A6A5165C} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoDX9", "Plugins\Plugin_VideoDX9\Plugin_VideoDX9.vcproj", "{636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoDX9", "Plugins\Plugin_VideoDX9\Plugin_VideoDX9.vcproj", "{636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18}" ProjectSection(ProjectDependencies) = postProject {11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED} {56C4B06E-F2C9-4729-A15A-DD327A9AA465} = {56C4B06E-F2C9-4729-A15A-DD327A9AA465} @@ -42,7 +42,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DiscIO", "Core\DiscIO\DiscI {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoOGL", "Plugins\Plugin_VideoOGL\Plugin_VideoOGL.vcproj", "{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoOGL", "Plugins\Plugin_VideoOGL\Plugin_VideoOGL.vcproj", "{CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160}" ProjectSection(ProjectDependencies) = postProject {C7E5D50A-2916-464B-86A7-E10B3CC88ADA} = {C7E5D50A-2916-464B-86A7-E10B3CC88ADA} {05C75041-D67D-4903-A362-8395A7B35C75} = {05C75041-D67D-4903-A362-8395A7B35C75} @@ -63,9 +63,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Common", "Core\Common\Commo EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Dolphin", "Core\DolphinWX\DolphinWX.vcproj", "{A72606EF-C5C1-4954-90AD-F0F93A8D97D9}" ProjectSection(ProjectDependencies) = postProject + {21DBE606-2958-43AC-A14E-B6B798D56554} = {21DBE606-2958-43AC-A14E-B6B798D56554} {C7E5D50A-2916-464B-86A7-E10B3CC88ADA} = {C7E5D50A-2916-464B-86A7-E10B3CC88ADA} + {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160} = {CFDCEE0E-FA45-4F72-9FCC-0B88F5A75160} {D4833C30-FA5F-4DFE-BD32-109DE1F09ED1} = {D4833C30-FA5F-4DFE-BD32-109DE1F09ED1} {05C75041-D67D-4903-A362-8395A7B35C75} = {05C75041-D67D-4903-A362-8395A7B35C75} + {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18} = {636FAD5F-02D1-4E9A-BE67-FB8EA99B9A18} {33546D62-7F34-4EA6-A88E-D538B36E16BF} = {33546D62-7F34-4EA6-A88E-D538B36E16BF} {11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED} {FBAFB369-07EB-4460-9CAD-08BE5789DAB6} = {FBAFB369-07EB-4460-9CAD-08BE5789DAB6} @@ -182,7 +185,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "wxCore28", "..\Externals\wx {B807E8DB-4241-4754-BC2A-2F435BCA881A} = {B807E8DB-4241-4754-BC2A-2F435BCA881A} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoSoftware", "Plugins\Plugin_VideoSoftware\Plugin_VideoSoftware.vcproj", "{66A4E7BD-E2E8-4373-9B75-8750EB5AE683}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoSoftware", "Plugins\Plugin_VideoSoftware\Plugin_VideoSoftware.vcproj", "{66A4E7BD-E2E8-4373-9B75-8750EB5AE683}" ProjectSection(ProjectDependencies) = postProject {11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED} {E5D1F0C0-AA07-4841-A4EB-4CF4DAA6B0FA} = {E5D1F0C0-AA07-4841-A4EB-4CF4DAA6B0FA} @@ -191,7 +194,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoSoftware", "Plu {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} = {C573CAF7-EE6A-458E-8049-16C0BF34C2E9} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoDX11", "Plugins\Plugin_VideoDX11\Plugin_VideoDX11.vcproj", "{21DBE606-2958-43AC-A14E-B6B798D56554}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoDX11", "Plugins\Plugin_VideoDX11\Plugin_VideoDX11.vcproj", "{21DBE606-2958-43AC-A14E-B6B798D56554}" ProjectSection(ProjectDependencies) = postProject {11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED} {56C4B06E-F2C9-4729-A15A-DD327A9AA465} = {56C4B06E-F2C9-4729-A15A-DD327A9AA465} @@ -582,9 +585,9 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - AMDCaProjectFile = G:\Dolphin\Source\CodeAnalyst\Dolphin.caw - AMDCaPersistentStartup = Dolphin AMDCaPersistentConfig = Release|x64 + AMDCaPersistentStartup = Dolphin + AMDCaProjectFile = G:\Dolphin\Source\CodeAnalyst\Dolphin.caw EndGlobalSection GlobalSection(DPCodeReviewSolutionGUID) = preSolution DPCodeReviewSolutionGUID = {00000000-0000-0000-0000-000000000000} diff --git a/Source/Dolphin_2010.sln b/Source/Dolphin_2010.sln index ace91779e006..8fe5a348f459 100644 --- a/Source/Dolphin_2010.sln +++ b/Source/Dolphin_2010.sln @@ -91,7 +91,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DiscIO", "Core\DiscIO\DiscI {C87A4178-44F6-49B2-B7AA-C79AF1B8C534} = {C87A4178-44F6-49B2-B7AA-C79AF1B8C534} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoDX9", "Plugins\Plugin_VideoDX9\Plugin_VideoDX9.vcxproj", "{DC7D7AF4-CE47-49E8-8B63-265CB6233A49}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "VideoDX9", "Plugins\Plugin_VideoDX9\Plugin_VideoDX9.vcxproj", "{DC7D7AF4-CE47-49E8-8B63-265CB6233A49}" ProjectSection(ProjectDependencies) = postProject {281F6001-D032-4C3B-87AF-0B00962B4006} = {281F6001-D032-4C3B-87AF-0B00962B4006} {3E5C4E02-1BA9-4776-BDBE-E3F91FFA34CF} = {3E5C4E02-1BA9-4776-BDBE-E3F91FFA34CF} @@ -118,24 +118,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_VideoSoftware", "Plu {3E5C4E02-1BA9-4776-BDBE-E3F91FFA34CF} = {3E5C4E02-1BA9-4776-BDBE-E3F91FFA34CF} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_DSP_HLE", "Plugins\Plugin_DSP_HLE\Plugin_DSP_HLE.vcxproj", "{27980B4B-F26C-41E8-9C44-A3D4F259D6E7}" - ProjectSection(ProjectDependencies) = postProject - {11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED} - {0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E} = {0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E} - {37D007BD-D66C-4EAF-B56C-BD1AAC340A05} = {37D007BD-D66C-4EAF-B56C-BD1AAC340A05} - {1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE} = {1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Plugin_DSP_LLE", "Plugins\Plugin_DSP_LLE\Plugin_DSP_LLE.vcxproj", "{14BF7DCF-8078-4FB4-B1E8-CDAC61271DFC}" - ProjectSection(ProjectDependencies) = postProject - {C5A30052-1FC7-4A30-B4A2-6B06DA298AB3} = {C5A30052-1FC7-4A30-B4A2-6B06DA298AB3} - {11F55366-12EC-4C44-A8CB-1D4E315D61ED} = {11F55366-12EC-4C44-A8CB-1D4E315D61ED} - {0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E} = {0E231FB1-F3C9-4724-ACCB-DE8BCB3C089E} - {37D007BD-D66C-4EAF-B56C-BD1AAC340A05} = {37D007BD-D66C-4EAF-B56C-BD1AAC340A05} - {4ED3C8BE-91A7-4361-8D46-16D03B678D4C} = {4ED3C8BE-91A7-4361-8D46-16D03B678D4C} - {1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE} = {1C8436C9-DBAF-42BE-83BC-CF3EC9175ABE} - EndProjectSection -EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "InputCommon", "Core\InputCommon\InputCommon.vcxproj", "{B39AC394-5DB5-4DA9-9D98-09D46CA3701F}" ProjectSection(ProjectDependencies) = postProject {C87A4178-44F6-49B2-B7AA-C79AF1B8C534} = {C87A4178-44F6-49B2-B7AA-C79AF1B8C534} @@ -456,28 +438,6 @@ Global {9E9DA440-E9AD-413C-B648-91030E792211}.Release|Win32.Build.0 = Release|Win32 {9E9DA440-E9AD-413C-B648-91030E792211}.Release|x64.ActiveCfg = Release|x64 {9E9DA440-E9AD-413C-B648-91030E792211}.Release|x64.Build.0 = Release|x64 - {27980B4B-F26C-41E8-9C44-A3D4F259D6E7}.Debug|Win32.ActiveCfg = Debug|Win32 - {27980B4B-F26C-41E8-9C44-A3D4F259D6E7}.Debug|Win32.Build.0 = Debug|Win32 - {27980B4B-F26C-41E8-9C44-A3D4F259D6E7}.Debug|x64.ActiveCfg = Debug|Win32 - {27980B4B-F26C-41E8-9C44-A3D4F259D6E7}.DebugFast|Win32.ActiveCfg = Release|Win32 - {27980B4B-F26C-41E8-9C44-A3D4F259D6E7}.DebugFast|Win32.Build.0 = Release|Win32 - {27980B4B-F26C-41E8-9C44-A3D4F259D6E7}.DebugFast|x64.ActiveCfg = DebugFast|x64 - {27980B4B-F26C-41E8-9C44-A3D4F259D6E7}.DebugFast|x64.Build.0 = DebugFast|x64 - {27980B4B-F26C-41E8-9C44-A3D4F259D6E7}.Release|Win32.ActiveCfg = Release|Win32 - {27980B4B-F26C-41E8-9C44-A3D4F259D6E7}.Release|Win32.Build.0 = Release|Win32 - {27980B4B-F26C-41E8-9C44-A3D4F259D6E7}.Release|x64.ActiveCfg = Release|x64 - {27980B4B-F26C-41E8-9C44-A3D4F259D6E7}.Release|x64.Build.0 = Release|x64 - {14BF7DCF-8078-4FB4-B1E8-CDAC61271DFC}.Debug|Win32.ActiveCfg = Debug|Win32 - {14BF7DCF-8078-4FB4-B1E8-CDAC61271DFC}.Debug|Win32.Build.0 = Debug|Win32 - {14BF7DCF-8078-4FB4-B1E8-CDAC61271DFC}.Debug|x64.ActiveCfg = Debug|Win32 - {14BF7DCF-8078-4FB4-B1E8-CDAC61271DFC}.DebugFast|Win32.ActiveCfg = Release|Win32 - {14BF7DCF-8078-4FB4-B1E8-CDAC61271DFC}.DebugFast|Win32.Build.0 = Release|Win32 - {14BF7DCF-8078-4FB4-B1E8-CDAC61271DFC}.DebugFast|x64.ActiveCfg = DebugFast|x64 - {14BF7DCF-8078-4FB4-B1E8-CDAC61271DFC}.DebugFast|x64.Build.0 = DebugFast|x64 - {14BF7DCF-8078-4FB4-B1E8-CDAC61271DFC}.Release|Win32.ActiveCfg = Release|Win32 - {14BF7DCF-8078-4FB4-B1E8-CDAC61271DFC}.Release|Win32.Build.0 = Release|Win32 - {14BF7DCF-8078-4FB4-B1E8-CDAC61271DFC}.Release|x64.ActiveCfg = Release|x64 - {14BF7DCF-8078-4FB4-B1E8-CDAC61271DFC}.Release|x64.Build.0 = Release|x64 {B39AC394-5DB5-4DA9-9D98-09D46CA3701F}.Debug|Win32.ActiveCfg = Debug|Win32 {B39AC394-5DB5-4DA9-9D98-09D46CA3701F}.Debug|Win32.Build.0 = Debug|Win32 {B39AC394-5DB5-4DA9-9D98-09D46CA3701F}.Debug|x64.ActiveCfg = Debug|x64 diff --git a/Source/PluginSpecs/ExportEpilog.h b/Source/PluginSpecs/ExportEpilog.h deleted file mode 100644 index 43b80149eac9..000000000000 --- a/Source/PluginSpecs/ExportEpilog.h +++ /dev/null @@ -1,6 +0,0 @@ -#undef EXPORT -#undef CALL - -#if defined(__cplusplus) -} -#endif diff --git a/Source/PluginSpecs/ExportProlog.h b/Source/PluginSpecs/ExportProlog.h deleted file mode 100644 index 99f5ca30641a..000000000000 --- a/Source/PluginSpecs/ExportProlog.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef _WIN32 - -#define EXPORT __declspec(dllexport) -#define CALL __cdecl - -#else - -#define EXPORT __attribute__ ((visibility("default"))) -#define CALL - -#endif - -#if defined(__cplusplus) -extern "C" { -#endif diff --git a/Source/PluginSpecs/PluginSpecs.h b/Source/PluginSpecs/PluginSpecs.h index ce30fa426875..d12c2a0c2119 100644 --- a/Source/PluginSpecs/PluginSpecs.h +++ b/Source/PluginSpecs/PluginSpecs.h @@ -9,7 +9,8 @@ // ------------ // TODO: See if we can get rid of the windows.h include. #ifdef _WIN32 - #include +#define WIN32_LEAN_AND_MEAN +#include #endif #include "Common.h" #include "CommonTypes.h" @@ -31,135 +32,28 @@ enum PLUGIN_COMM // System specific declarations and definitions // ------------ -#ifdef _WIN32 - #define EXPORT __declspec(dllexport) - #define CALL __cdecl -#else - #define EXPORT __attribute__ ((visibility("default"))) - #define __cdecl - #define CALL - #ifndef TRUE - #define TRUE 1 - #define FALSE 0 - #endif -#endif - -#if defined(__cplusplus) - extern "C" { +// TODO: get rid of this i think +#if !defined(_WIN32) && !defined(TRUE) +#define TRUE 1 +#define FALSE 0 #endif - - // Global values // ------------ -// Plugin types -enum PLUGIN_TYPE { - PLUGIN_TYPE_VIDEO = 1, -}; - -#define STATE_MODE_READ 1 -#define STATE_MODE_WRITE 2 -#define STATE_MODE_MEASURE 3 +//enum STATE_MODE +//{ +// STATE_MODE_READ = 1, +// STATE_MODE_WRITE, +// STATE_MODE_MEASURE, +//}; // used for notification on emulation state -enum PLUGIN_EMUSTATE { +enum PLUGIN_EMUSTATE +{ PLUGIN_EMUSTATE_PLAY = 1, PLUGIN_EMUSTATE_PAUSE, PLUGIN_EMUSTATE_STOP, }; -// Export structs -// ------------ -typedef struct -{ - u16 Version; // Set to 0x0100 - PLUGIN_TYPE Type; // Set to PLUGIN_TYPE_DVD - char Name[100]; // Name of the DLL -} PLUGIN_INFO; - -// TODO: Remove, or at least remove the void pointers and replace with data. -// This design is just wrong and ugly - the plugins shouldn't have this much access. -typedef struct -{ - void *was_eventHandler_but_lets_not_break_abi; - void *logManager; - char game_ini[MAX_PATH]; - char unique_id[16]; -} PLUGIN_GLOBALS; - -// GLOBAL I N T E R F A C E -// ____________________________________________________________________________ -// Function: GetDllInfo -// Purpose: This function allows the emulator to gather information -// about the DLL by filling in the PluginInfo structure. -// input: A pointer to a PLUGIN_INFO structure that needs to be -// filled by the function. (see def above) -// output: none -// -EXPORT void CALL GetDllInfo(PLUGIN_INFO* _pPluginInfo); - -// ___________________________________________________________________________ -// Function: DllConfig -// Purpose: This function is optional function that is provided -// to allow the user to configure the DLL -// input: A handle to the window that calls this function -// output: none -// -EXPORT void CALL DllConfig(void *_hParent); - -// ___________________________________________________________________________ -// Function: DllDebugger -// Purpose: Open the debugger -// input: a handle to the window that calls this function -// output: none -// -EXPORT void* CALL DllDebugger(void *_hParent, bool Show); - -// ___________________________________________________________________________ -// Function: DllSetGlobals -// Purpose: Set the pointer for globals variables -// input: a pointer to the global struct -// output: none -// -EXPORT void CALL SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals); - -// ___________________________________________________________________________ -// Function: Initialize -// Purpose: Initialize the plugin -// input: Init -// output: none -// -EXPORT void CALL Initialize(void *init); - -// ___________________________________________________________________________ -// Function: Shutdown -// Purpose: This function is called when the emulator is shutting down -// a game allowing the dll to de-initialise. -// input: none -// output: none -// -EXPORT void CALL Shutdown(void); - -// ___________________________________________________________________________ -// Function: DoState -// Purpose: Saves/load state -// input/output: ptr -// input: mode -// -EXPORT void CALL DoState(unsigned char **ptr, int mode); - -// ___________________________________________________________________________ -// Function: EmuStateChange -// Purpose: Notifies the plugin of a change in emulation state -// input: newState -// output: none -// -EXPORT void CALL EmuStateChange(PLUGIN_EMUSTATE newState); - - -#if defined(__cplusplus) - } -#endif - #endif // _PLUGINS_H_INCLUDED__ diff --git a/Source/PluginSpecs/pluginspecs_video.h b/Source/PluginSpecs/pluginspecs_video.h deleted file mode 100644 index d337374c02d9..000000000000 --- a/Source/PluginSpecs/pluginspecs_video.h +++ /dev/null @@ -1,208 +0,0 @@ -//__________________________________________________________________________________________________ -// Common video plugin spec, version #1.0 maintained by F|RES -// - -#ifndef _VIDEO_H_INCLUDED__ -#define _VIDEO_H_INCLUDED__ - -#include "PluginSpecs.h" - -#include "ExportProlog.h" - -typedef void (*TimedCallback)(u64 userdata, int cyclesLate); - -typedef void (*TSetInterrupt)(u32 _causemask, bool _bSet); -typedef int (*TRegisterEvent)(const char *name, TimedCallback callback); -typedef void (*TScheduleEvent_Threadsafe)(int cyclesIntoFuture, int event_type, u64 userdata); -typedef void (*TRemoveEvent)(int event_type); -typedef void (*TProcessFifoEvents)(void); -typedef unsigned char* (*TGetMemoryPointer)(const unsigned int _iAddress); -typedef void (*TVideoLog)(const char* _pMessage, int _bBreak); -typedef void (*TSysMessage)(const char *fmt, ...); -typedef void (*TGetWindowSize)(int& x, int& y, int& width, int& height); -typedef void (*TRequestWindowSize)(int& width, int& height); -typedef void (*TCopiedToXFB)(bool video_update); -typedef unsigned int (*TPeekMessages)(void); -typedef void (*TUpdateFPSDisplay)(const char* text); // sets the window title -typedef void (*TCoreMessage)(int Id); // passes message to the core -typedef void (*TResetGatherPipe)(void); - -enum FieldType -{ - FIELD_PROGRESSIVE = 0, - FIELD_UPPER, - FIELD_LOWER -}; - -enum EFBAccessType -{ - PEEK_Z = 0, - POKE_Z, - PEEK_COLOR, - POKE_COLOR -}; - -typedef struct -{ - // fifo registers - volatile u32 CPBase; - volatile u32 CPEnd; - u32 CPHiWatermark; - u32 CPLoWatermark; - volatile u32 CPReadWriteDistance; - volatile u32 CPWritePointer; - volatile u32 CPReadPointer; - volatile u32 CPBreakpoint; - - // Super Monkey Ball Adventure require this. - // Because the read&check-PEToken-loop stays in its JITed block I suppose. - // So no possiblity to ack the Token irq by the scheduler until some sort of PPC watchdog do its mess. - volatile u16 PEToken; - - volatile u32 bFF_GPReadEnable; - volatile u32 bFF_BPEnable; - volatile u32 bFF_BPInt; - volatile u32 bFF_Breakpoint; - - volatile u32 CPCmdIdle; - volatile u32 CPReadIdle; - - volatile u32 bFF_LoWatermarkInt; - volatile u32 bFF_HiWatermarkInt; - - volatile u32 bFF_LoWatermark; - volatile u32 bFF_HiWatermark; - - // for GP watchdog hack - volatile u32 Fake_GPWDToken; // cicular incrementer -} SCPFifoStruct; - -typedef struct -{ - void *pWindowHandle; - - TSetInterrupt pSetInterrupt; - TRegisterEvent pRegisterEvent; - TScheduleEvent_Threadsafe pScheduleEvent_Threadsafe; - TRemoveEvent pRemoveEvent; - TProcessFifoEvents pProcessFifoEvents; - TGetMemoryPointer pGetMemoryPointer; - TVideoLog pLog; - TSysMessage pSysMessage; - TGetWindowSize pGetWindowSize; - TRequestWindowSize pRequestWindowSize; - TCopiedToXFB pCopiedToXFB; - TPeekMessages pPeekMessages; - TUpdateFPSDisplay pUpdateFPSDisplay; - TCoreMessage pCoreMessage; - TResetGatherPipe pResetGatherPipe; - void *pMemoryBase; - bool bWii; - bool bOnThread; - u32 *Fifo_CPUBase; - u32 *Fifo_CPUEnd; - u32 *Fifo_CPUWritePointer; - bool bAutoAspectIs16_9; -} SVideoInitialize; - - -// I N T E R F A C E - - -// __________________________________________________________________________________________________ -// Function: Video_Prepare -// Purpose: This function is called from the EmuThread before the -// emulation has started. It is just for threadsensitive -// APIs like OpenGL. -// input: none -// output: none -// -EXPORT void CALL Video_Prepare(void); - -// __________________________________________________________________________________________________ -// Function: Video_BeginField -// Purpose: When a field begins in the VI emulator, this function tells the video plugin what the -// parameters of the upcoming field are. The video plugin should make sure the previous -// field is on the player's display before returning. -// input: vi parameters of the upcoming field -// output: none -// -EXPORT void CALL Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight); - -// __________________________________________________________________________________________________ -// Function: Video_EndField -// Purpose: When a field ends in the VI emulator, this function notifies the video plugin. The video -// has permission to swap the field to the player's display. -// input: none -// output: none -// -EXPORT void CALL Video_EndField(); - -// __________________________________________________________________________________________________ -// Function: Video_AccessEFB -// input: type of access (r/w, z/color, ...), x coord, y coord -// output: response to the access request (ex: peek z data at specified coord) -// -EXPORT u32 CALL Video_AccessEFB(EFBAccessType type, u32 x, u32 y,u32 InputData); - -// __________________________________________________________________________________________________ -// Function: Video_Screenshot -// input: Filename -// output: TRUE if all was okay -// -EXPORT void CALL Video_Screenshot(const char *_szFilename); - -// __________________________________________________________________________________________________ -// Function: Video_EnterLoop -// Purpose: Enters the video fifo dispatch loop. This is only used in Dual Core mode. -// input: none -// output: none -// -EXPORT void CALL Video_EnterLoop(void); - -// __________________________________________________________________________________________________ -// Function: Video_ExitLoop -// Purpose: Exits the video dispatch loop. This is only used in Dual Core mode. -// input: none -// output: none -// -EXPORT void CALL Video_ExitLoop(void); - -// __________________________________________________________________________________________________ -// Function: Video_SetRendering -// Purpose: Sets video rendering on and off. Currently used for frame skipping -// input: Enabled toggle -// output: none -// -EXPORT void CALL Video_SetRendering(bool bEnabled); - -// __________________________________________________________________________________________________ -// Function: Video_AddMessage -// Purpose: Adds a message to the display queue, to be shown forthe specified time -// input: pointer to the null-terminated string, time in milliseconds -// output: none -// -EXPORT void CALL Video_AddMessage(const char* pstr, unsigned int milliseconds); - -EXPORT void CALL Video_CommandProcessorRead16(u16& _rReturnValue, const u32 _Address); -EXPORT void CALL Video_CommandProcessorWrite16(const u16 _Data, const u32 _Address); -EXPORT void CALL Video_PixelEngineRead16(u16& _rReturnValue, const u32 _Address); -EXPORT void CALL Video_PixelEngineWrite16(const u16 _Data, const u32 _Address); -EXPORT void CALL Video_PixelEngineWrite32(const u32 _Data, const u32 _Address); -EXPORT void CALL Video_GatherPipeBursted(void); -EXPORT void CALL Video_WaitForFrameFinish(void); - -// __________________________________________________________________________________________________ -// Function: Video_IsFifoBusy -// Purpose: Return if the FIFO is proecessing data, that is used for sync gfx thread and emulator -// thread in CoreTiming -// input: none -// output: bool -// -EXPORT bool CALL Video_IsFifoBusy(void); - -EXPORT void CALL Video_AbortFrame(void); - - -#include "ExportEpilog.h" -#endif diff --git a/Source/Plugins/Plugin_VideoDX11/Plugin_VideoDX11.vcproj b/Source/Plugins/Plugin_VideoDX11/Plugin_VideoDX11.vcproj index 3f5ff8364d43..06f73ff7b2e9 100644 --- a/Source/Plugins/Plugin_VideoDX11/Plugin_VideoDX11.vcproj +++ b/Source/Plugins/Plugin_VideoDX11/Plugin_VideoDX11.vcproj @@ -2,7 +2,7 @@ - @@ -118,9 +103,6 @@ - @@ -129,7 +111,7 @@ Name="Release|x64" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -166,7 +148,7 @@ FavorSizeOrSpeed="1" OmitFramePointers="false" WholeProgramOptimization="true" - AdditionalIncludeDirectories="../../../Externals;../../PluginSpecs;../../Core/Common/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc" + AdditionalIncludeDirectories="../../../Externals;../../PluginSpecs;../../Core/Common/Src;../../Core/Core/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;VIDEO_DIRECTX11_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0" StringPooling="true" ExceptionHandling="1" @@ -198,27 +180,11 @@ Name="VCPreLinkEventTool" /> - @@ -228,9 +194,6 @@ - @@ -239,7 +202,7 @@ Name="Debug|Win32" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -269,7 +232,7 @@ - @@ -325,9 +272,6 @@ - @@ -336,7 +280,7 @@ Name="Debug|x64" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -366,7 +310,7 @@ - @@ -421,9 +350,6 @@ - @@ -432,7 +358,7 @@ Name="DebugFast|Win32" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -468,7 +394,7 @@ FavorSizeOrSpeed="1" OmitFramePointers="false" WholeProgramOptimization="true" - AdditionalIncludeDirectories="../../../Externals;../../PluginSpecs;../../Core/Common/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc" + AdditionalIncludeDirectories="../../../Externals;../../PluginSpecs;../../Core/Common/Src;../../Core/Core/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc" PreprocessorDefinitions="_WIN32;WIN32;NDEBUG;_WINDOWS;_USRDLL;VIDEO_DIRECTX11_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;DEBUGFAST" StringPooling="true" RuntimeLibrary="0" @@ -498,27 +424,11 @@ Name="VCPreLinkEventTool" /> - @@ -528,9 +438,6 @@ - @@ -539,7 +446,7 @@ Name="DebugFast|x64" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -576,7 +483,7 @@ FavorSizeOrSpeed="1" OmitFramePointers="false" WholeProgramOptimization="true" - AdditionalIncludeDirectories="../../../Externals;../../PluginSpecs;../../Core/Common/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc" + AdditionalIncludeDirectories="../../../Externals;../../PluginSpecs;../../Core/Common/Src;../../Core/Core/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;VIDEO_DIRECTX11_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;;DEBUGFAST" StringPooling="true" ExceptionHandling="1" @@ -607,26 +514,11 @@ Name="VCPreLinkEventTool" /> - @@ -636,9 +528,6 @@ - diff --git a/Source/Plugins/Plugin_VideoDX11/Plugin_VideoDX11.vcxproj b/Source/Plugins/Plugin_VideoDX11/Plugin_VideoDX11.vcxproj index 874e5c0e09e1..1bef693a55ba 100644 --- a/Source/Plugins/Plugin_VideoDX11/Plugin_VideoDX11.vcxproj +++ b/Source/Plugins/Plugin_VideoDX11/Plugin_VideoDX11.vcxproj @@ -29,38 +29,39 @@ {9A4C733C-BADE-4AC6-B58A-6E274395E90E} Plugin_VideoDX11 + VideoDX11 - DynamicLibrary + StaticLibrary true Unicode - DynamicLibrary + StaticLibrary true Unicode - DynamicLibrary + StaticLibrary false true Unicode - DynamicLibrary + StaticLibrary false true Unicode - DynamicLibrary + StaticLibrary false true Unicode - DynamicLibrary + StaticLibrary false true Unicode @@ -131,7 +132,7 @@ Level3 Disabled - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreadedDebug stdafx.h @@ -147,7 +148,7 @@ Level3 Disabled - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreadedDebug stdafx.h @@ -165,7 +166,7 @@ MaxSpeed true true - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded stdafx.h @@ -205,7 +206,7 @@ MaxSpeed true true - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded stdafx.h @@ -287,6 +288,7 @@ + diff --git a/Source/Plugins/Plugin_VideoDX11/Src/Globals.h b/Source/Plugins/Plugin_VideoDX11/Src/Globals.h index f1c13d728c65..43f926309175 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/Globals.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/Globals.h @@ -23,9 +23,5 @@ #include "main.h" #include "VideoCommon.h" -#include "pluginspecs_video.h" - -// A global plugin specification -extern PLUGIN_GLOBALS* globals; #endif // _GLOBALS_H_ \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX11/Src/NativeVertexFormat.cpp b/Source/Plugins/Plugin_VideoDX11/Src/NativeVertexFormat.cpp index 6fd6f694eb95..bfa70948da54 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/NativeVertexFormat.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/NativeVertexFormat.cpp @@ -22,6 +22,9 @@ #include "VertexManager.h" #include "VertexShaderCache.h" +namespace DX11 +{ + class D3DVertexFormat : public NativeVertexFormat { D3D11_INPUT_ELEMENT_DESC m_elems[32]; @@ -38,16 +41,11 @@ class D3DVertexFormat : public NativeVertexFormat void SetupVertexPointers(); }; -namespace DX11 -{ - NativeVertexFormat* VertexManager::CreateNativeVertexFormat() { return new D3DVertexFormat(); } -} - DXGI_FORMAT VarToD3D(VarType t, int size) { DXGI_FORMAT retval = DXGI_FORMAT_UNKNOWN; @@ -155,3 +153,5 @@ void D3DVertexFormat::SetupVertexPointers() } DX11::D3D::context->IASetInputLayout(m_layout); } + +} // namespace DX11 diff --git a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp index 1a3140bc2aca..5efb9354dddf 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.cpp @@ -28,6 +28,8 @@ #include "PixelShaderGen.h" #include "PixelShaderCache.h" +#include "ConfigManager.h" + extern int frameCount; // See comment near the bottom of this file. @@ -37,7 +39,6 @@ bool pscbufchanged = true; namespace DX11 { - PixelShaderCache::PSCache PixelShaderCache::PixelShaders; const PixelShaderCache::PSCacheEntry* PixelShaderCache::last_entry; @@ -271,7 +272,7 @@ void PixelShaderCache::Init() SETSTAT(stats.numPixelShadersAlive, 0); char cache_filename[MAX_PATH]; - sprintf(cache_filename, "%sdx11-%s-ps.cache", File::GetUserPath(D_SHADERCACHE_IDX), globals->unique_id); + sprintf(cache_filename, "%sdx11-%s-ps.cache", File::GetUserPath(D_SHADERCACHE_IDX), SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); PixelShaderCacheInserter inserter; g_ps_disk_cache.OpenAndRead(cache_filename, inserter); } @@ -386,9 +387,6 @@ bool PixelShaderCache::InsertByteCode(const PIXELSHADERUID &uid, const void* byt return true; } -} // DX11 - - // These are "callbacks" from VideoCommon and thus must be outside namespace DX11. // This will have to be changed when we merge. @@ -414,7 +412,7 @@ static const unsigned int ps_constant_offset_table[] = { 260, 264, 268, 272, 276, // C_PLIGHTS7, 20 280, 284, 288, 292 // C_PMATERIALS, 16 }; -void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) +void Renderer::SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { psconstants[ps_constant_offset_table[const_number] ] = f1; psconstants[ps_constant_offset_table[const_number]+1] = f2; @@ -423,14 +421,16 @@ void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, fl pscbufchanged = true; } -void SetPSConstant4fv(unsigned int const_number, const float* f) +void Renderer::SetPSConstant4fv(unsigned int const_number, const float* f) { memcpy(&psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4); pscbufchanged = true; } -void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float* f) +void Renderer::SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float* f) { memcpy(&psconstants[ps_constant_offset_table[const_number]], f, sizeof(float)*4*count); pscbufchanged = true; } + +} // DX11 diff --git a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.h b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.h index 29454e73c388..b3b17e132ca0 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/PixelShaderCache.h @@ -24,7 +24,8 @@ class PIXELSHADERUID; enum DSTALPHA_MODE; -namespace DX11 { +namespace DX11 +{ class PixelShaderCache { @@ -61,4 +62,4 @@ class PixelShaderCache static const PSCacheEntry* last_entry; }; -} // namespace DX11 \ No newline at end of file +} // namespace DX11 diff --git a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp index 16454bbb080d..b7d3db43826f 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/Render.cpp @@ -38,7 +38,7 @@ #include "Render.h" #include "TextureCache.h" #include "VertexShaderCache.h" - +#include "Core.h" namespace DX11 { @@ -313,7 +313,7 @@ Renderer::Renderer() int x, y, w_temp, h_temp; s_blendMode = 0; - g_VideoInitialize.pGetWindowSize(x, y, w_temp, h_temp); + Core::Callback_VideoGetWindowSize(x, y, w_temp, h_temp); D3D::Create(EmuWindow::GetWnd()); @@ -447,7 +447,7 @@ void Renderer::SetWindowSize(int width, int height) // Scale the window size by the EFB scale. CalculateTargetScale(width, height, width, height); - g_VideoInitialize.pRequestWindowSize(width, height); + Core::Callback_VideoRequestWindowSize(width, height); } bool Renderer::SetScissorRect() @@ -897,7 +897,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons { if (g_bSkipCurrentFrame || (!XFBWrited && (!g_ActiveConfig.bUseXFB || !g_ActiveConfig.bUseRealXFB)) || !fbWidth || !fbHeight) { - g_VideoInitialize.pCopiedToXFB(false); + Core::Callback_VideoCopiedToXFB(false); return; } // this function is called after the XFB field is changed, not after @@ -909,7 +909,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount); if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB) { - g_VideoInitialize.pCopiedToXFB(false); + Core::Callback_VideoCopiedToXFB(false); return; } @@ -1120,7 +1120,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons UpdateViewport(); VertexShaderManager::SetViewportChanged(); - g_VideoInitialize.pCopiedToXFB(XFBWrited || (g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB)); + Core::Callback_VideoCopiedToXFB(XFBWrited || (g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB)); XFBWrited = false; } diff --git a/Source/Plugins/Plugin_VideoDX11/Src/Render.h b/Source/Plugins/Plugin_VideoDX11/Src/Render.h index 4a006ce7e4d5..44631736fcef 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/Render.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/Render.h @@ -49,6 +49,15 @@ class Renderer : public ::Renderer static bool CheckForResize(); static void SetWindowSize(int width, int height); + + void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4); + void SetPSConstant4fv(unsigned int const_number, const float *f); + void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f); + + void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4); + void SetVSConstant4fv(unsigned int const_number, const float *f); + void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f); + void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f); }; } diff --git a/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp index 8f575aced7fc..6619852d8832 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/VertexShaderCache.cpp @@ -26,6 +26,8 @@ #include "Globals.h" #include "VertexShaderCache.h" +#include "ConfigManager.h" + // See comment near the bottom of this file static unsigned int vs_constant_offset_table[C_VENVCONST_END]; float vsconstants[C_VENVCONST_END*4]; @@ -168,7 +170,7 @@ void VertexShaderCache::Init() SETSTAT(stats.numVertexShadersAlive, 0); char cache_filename[MAX_PATH]; - sprintf(cache_filename, "%sdx11-%s-vs.cache", File::GetUserPath(D_SHADERCACHE_IDX), globals->unique_id); + sprintf(cache_filename, "%sdx11-%s-vs.cache", File::GetUserPath(D_SHADERCACHE_IDX), SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); VertexShaderCacheInserter inserter; g_vs_disk_cache.OpenAndRead(cache_filename, inserter); } @@ -264,13 +266,11 @@ bool VertexShaderCache::InsertByteCode(const VERTEXSHADERUID &uid, D3DBlob* bcod return true; } -} // namespace DX11 - // These are "callbacks" from VideoCommon and thus must be outside namespace DX11. // This will have to be changed when we merge. // maps the constant numbers to float indices in the constant buffer -void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) +void Renderer::SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { vsconstants[vs_constant_offset_table[const_number] ] = f1; vsconstants[vs_constant_offset_table[const_number]+1] = f2; @@ -279,13 +279,13 @@ void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, fl vscbufchanged = true; } -void SetVSConstant4fv(unsigned int const_number, const float* f) +void Renderer::SetVSConstant4fv(unsigned int const_number, const float* f) { memcpy(&vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4); vscbufchanged = true; } -void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float* f) +void Renderer::SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float* f) { for (unsigned int i = 0; i < count; i++) { @@ -295,8 +295,10 @@ void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const vscbufchanged = true; } -void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float* f) +void Renderer::SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float* f) { memcpy(&vsconstants[vs_constant_offset_table[const_number]], f, sizeof(float)*4*count); vscbufchanged = true; -} \ No newline at end of file +} + +} // namespace DX11 diff --git a/Source/Plugins/Plugin_VideoDX11/Src/VideoBackend.h b/Source/Plugins/Plugin_VideoDX11/Src/VideoBackend.h new file mode 100644 index 000000000000..3493a4b74dfc --- /dev/null +++ b/Source/Plugins/Plugin_VideoDX11/Src/VideoBackend.h @@ -0,0 +1,27 @@ + +#ifndef DX11_VIDEO_BACKEND_H_ +#define DX11_VIDEO_BACKEND_H_ + +#include "VideoBackendBase.h" + +namespace DX11 +{ + +class VideoBackend : public VideoBackendHLE +{ + void Initialize(); + void Shutdown(); + + std::string GetName(); + + void Video_Prepare(); + + void ShowConfig(void* parent); + + void UpdateFPSDisplay(const char*); + unsigned int PeekMessages(); +}; + +} + +#endif diff --git a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp index 74f8c7e5509f..7536cca901ea 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX11/Src/main.cpp @@ -30,6 +30,7 @@ #include "VertexLoaderManager.h" #include "VertexShaderManager.h" #include "XFBConvert.h" +#include "Core.h" #include "DebuggerPanel.h" #include "DLCache.h" @@ -46,83 +47,18 @@ #include "VertexManager.h" #include "VertexShaderCache.h" +#include "VideoBackend.h" +#include "ConfigManager.h" -HINSTANCE g_hInstance = NULL; - -wxLocale *InitLanguageSupport() +namespace DX11 { - wxLocale *m_locale; - unsigned int language = 0; - - IniFile ini; - ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); - ini.Get("Interface", "Language", &language, wxLANGUAGE_DEFAULT); - - // Load language if possible, fall back to system default otherwise - if(wxLocale::IsAvailable(language)) - { - m_locale = new wxLocale(language); - - m_locale->AddCatalogLookupPathPrefix(wxT("Languages")); - m_locale->AddCatalog(wxT("dolphin-emu")); - - if(!m_locale->IsOk()) - { - PanicAlertT("Error loading selected language. Falling back to system default."); - delete m_locale; - m_locale = new wxLocale(wxLANGUAGE_DEFAULT); - } - } - else - { - PanicAlertT("The selected language is not supported by your system. Falling back to system default."); - m_locale = new wxLocale(wxLANGUAGE_DEFAULT); - } - return m_locale; -} - -// This is used for the functions right below here which use wxwidgets -WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); - -void *DllDebugger(void *_hParent, bool Show) +void*& VideoWindowHandle() { - return new GFXDebuggerPanel((wxWindow*)_hParent); + return SConfig::GetInstance().m_LocalCoreStartupParameter.hMainWindow; } -class wxDLLApp : public wxApp -{ - bool OnInit() - { - return true; - } -}; -IMPLEMENT_APP_NO_MAIN(wxDLLApp) -WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); - -BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved) -{ - static wxLocale *m_locale; - switch (dwReason) - { - case DLL_PROCESS_ATTACH: - { - wxSetInstance((HINSTANCE)hinstDLL); - wxInitialize(); - m_locale = InitLanguageSupport(); - } - break; - case DLL_PROCESS_DETACH: - wxUninitialize(); - delete m_locale; - break; - } - - g_hInstance = hinstDLL; - return TRUE; -} - -unsigned int Callback_PeekMessages() +unsigned int VideoBackend::PeekMessages() { MSG msg; while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) @@ -135,31 +71,29 @@ unsigned int Callback_PeekMessages() return TRUE; } - -void UpdateFPSDisplay(const char *text) +void VideoBackend::UpdateFPSDisplay(const char *text) { char temp[512]; sprintf_s(temp, sizeof temp, "%s | DX11 | %s", svn_rev_str, text); SetWindowTextA(EmuWindow::GetWnd(), temp); } -void GetDllInfo(PLUGIN_INFO* _PluginInfo) +//void GetDllInfo(PLUGIN_INFO* _PluginInfo) +//{ +// _PluginInfo->Version = 0x0100; +// //_PluginInfo->Type = PLUGIN_TYPE_VIDEO; +//#ifdef DEBUGFAST +// sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D11 (DebugFast)"); +//#elif defined _DEBUG +// sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D11 (Debug)"); +//#else +// sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D11"); +//#endif +//} + +std::string VideoBackend::GetName() { - _PluginInfo->Version = 0x0100; - _PluginInfo->Type = PLUGIN_TYPE_VIDEO; -#ifdef DEBUGFAST - sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D11 (DebugFast)"); -#elif defined _DEBUG - sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D11 (Debug)"); -#else - sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D11"); -#endif -} - -void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) -{ - globals = _pPluginGlobals; - LogManager::SetInstance((LogManager*)globals->logManager); + return "Direct3D11"; } void InitBackendInfo() @@ -175,7 +109,7 @@ void InitBackendInfo() g_Config.backend_info.bSupportsPixelLighting = true; } -void DllConfig(void *_hParent) +void VideoBackend::ShowConfig(void *_hParent) { #if defined(HAVE_WX) && HAVE_WX InitBackendInfo(); @@ -234,42 +168,30 @@ void DllConfig(void *_hParent) #endif } -void Initialize(void *init) +void VideoBackend::Initialize() { InitBackendInfo(); frameCount = 0; - SVideoInitialize *_pVideoInitialize = (SVideoInitialize*)init; - // Create a shortcut to _pVideoInitialize that can also update it - g_VideoInitialize = *(_pVideoInitialize); InitXFBConvTables(); g_Config.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_dx11.ini").c_str()); - g_Config.GameIniLoad(globals->game_ini); + g_Config.GameIniLoad(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strGameIni.c_str()); UpdateProjectionHack(g_Config.iPhackvalue, g_Config.sPhackvalue); UpdateActiveConfig(); - g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, _T("Loading - Please wait.")); - if (g_VideoInitialize.pWindowHandle == NULL) + VideoWindowHandle() = (void*)EmuWindow::Create((HWND)VideoWindowHandle(), GetModuleHandle(0), _T("Loading - Please wait.")); + if (VideoWindowHandle() == NULL) { ERROR_LOG(VIDEO, "An error has occurred while trying to create the window."); return; } - g_VideoInitialize.pPeekMessages = &Callback_PeekMessages; - g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay; - - _pVideoInitialize->pPeekMessages = g_VideoInitialize.pPeekMessages; - _pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay; - - // Now the window handle is written - _pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle; - OSD::AddMessage("Dolphin Direct3D11 Video Plugin.", 5000); s_PluginInitialized = true; } -void Video_Prepare() +void VideoBackend::Video_Prepare() { // Better be safe... s_efbAccessRequested = FALSE; @@ -277,12 +199,12 @@ void Video_Prepare() s_swapRequested = FALSE; // internal interfaces - g_renderer = new DX11::Renderer; - g_texture_cache = new DX11::TextureCache; - g_vertex_manager = new DX11::VertexManager; - DX11::VertexShaderCache::Init(); - DX11::PixelShaderCache::Init(); - DX11::D3D::InitUtils(); + g_renderer = new Renderer; + g_texture_cache = new TextureCache; + g_vertex_manager = new VertexManager; + VertexShaderCache::Init(); + PixelShaderCache::Init(); + D3D::InitUtils(); // VideoCommon BPInit(); @@ -296,10 +218,10 @@ void Video_Prepare() DLCache::Init(); // Tell the host that the window is ready - g_VideoInitialize.pCoreMessage(WM_USER_CREATE); + Core::Callback_CoreMessage(WM_USER_CREATE); } -void Shutdown() +void VideoBackend::Shutdown() { s_PluginInitialized = false; @@ -317,9 +239,9 @@ void Shutdown() VertexLoaderManager::Shutdown(); // internal interfaces - DX11::D3D::ShutdownUtils(); - DX11::PixelShaderCache::Shutdown(); - DX11::VertexShaderCache::Shutdown(); + D3D::ShutdownUtils(); + PixelShaderCache::Shutdown(); + VertexShaderCache::Shutdown(); delete g_vertex_manager; delete g_texture_cache; delete g_renderer; @@ -327,3 +249,5 @@ void Shutdown() s_PluginInitialized = false; } + +} diff --git a/Source/Plugins/Plugin_VideoDX11/Src/main.h b/Source/Plugins/Plugin_VideoDX11/Src/main.h index 1a0ee15e9bc0..d8c5ac493341 100644 --- a/Source/Plugins/Plugin_VideoDX11/Src/main.h +++ b/Source/Plugins/Plugin_VideoDX11/Src/main.h @@ -18,10 +18,7 @@ #ifndef MAIN_H #define MAIN_H -#include "PluginSpecs_Video.h" #include "Render.h" #include "MainBase.h" -extern SVideoInitialize g_VideoInitialize; - #endif diff --git a/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj b/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj index a40ae00c8156..946e25b920d9 100644 --- a/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj +++ b/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcproj @@ -2,7 +2,7 @@ - @@ -120,9 +105,6 @@ - @@ -131,7 +113,7 @@ Name="Release|x64" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -168,7 +150,7 @@ FavorSizeOrSpeed="1" OmitFramePointers="false" WholeProgramOptimization="true" - AdditionalIncludeDirectories="../../../Externals;../../PluginSpecs;../../Core/Common/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc" + AdditionalIncludeDirectories="../../../Externals;../../PluginSpecs;../../Core/Common/Src;../../Core/Core/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;VIDEO_DIRECTX9_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0" StringPooling="true" ExceptionHandling="1" @@ -202,27 +184,11 @@ Name="VCPreLinkEventTool" /> - @@ -232,9 +198,6 @@ - @@ -243,7 +206,7 @@ Name="Debug|Win32" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -273,7 +236,7 @@ - @@ -331,9 +278,6 @@ - @@ -342,7 +286,7 @@ Name="Debug|x64" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -372,7 +316,7 @@ - @@ -429,9 +358,6 @@ - @@ -440,7 +366,7 @@ Name="DebugFast|Win32" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -476,7 +402,7 @@ FavorSizeOrSpeed="1" OmitFramePointers="false" WholeProgramOptimization="true" - AdditionalIncludeDirectories="../../../Externals;../../PluginSpecs;../../Core/Common/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc" + AdditionalIncludeDirectories="../../../Externals;../../PluginSpecs;../../Core/Common/Src;../../Core/Core/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc" PreprocessorDefinitions="_WIN32;WIN32;NDEBUG;_WINDOWS;_USRDLL;VIDEO_DIRECTX9_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;DEBUGFAST" StringPooling="true" RuntimeLibrary="0" @@ -508,27 +434,11 @@ Name="VCPreLinkEventTool" /> - @@ -538,9 +448,6 @@ - @@ -549,7 +456,7 @@ Name="DebugFast|x64" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -586,7 +493,7 @@ FavorSizeOrSpeed="1" OmitFramePointers="false" WholeProgramOptimization="true" - AdditionalIncludeDirectories="../../../Externals;../../PluginSpecs;../../Core/Common/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc" + AdditionalIncludeDirectories="../../../Externals;../../PluginSpecs;../../Core/Common/Src;../../Core/Core/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;VIDEO_DIRECTX9_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;;DEBUGFAST" StringPooling="true" ExceptionHandling="1" @@ -619,26 +526,11 @@ Name="VCPreLinkEventTool" /> - @@ -648,9 +540,6 @@ - diff --git a/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcxproj b/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcxproj index a3ed0e032c5c..5afabd65bde3 100644 --- a/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcxproj +++ b/Source/Plugins/Plugin_VideoDX9/Plugin_VideoDX9.vcxproj @@ -29,38 +29,39 @@ {DC7D7AF4-CE47-49E8-8B63-265CB6233A49} Plugin_VideoDX9 + VideoDX9 - DynamicLibrary + StaticLibrary true Unicode - DynamicLibrary + StaticLibrary true Unicode - DynamicLibrary + StaticLibrary false true Unicode - DynamicLibrary + StaticLibrary false true Unicode - DynamicLibrary + StaticLibrary false true Unicode - DynamicLibrary + StaticLibrary false true Unicode @@ -131,7 +132,7 @@ Level3 Disabled - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreadedDebug stdafx.h @@ -146,7 +147,7 @@ Level3 Disabled - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreadedDebug stdafx.h @@ -163,7 +164,7 @@ MaxSpeed true true - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded stdafx.h @@ -182,7 +183,7 @@ MaxSpeed true true - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) DEBUGFAST;_SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded stdafx.h @@ -201,7 +202,7 @@ MaxSpeed true true - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded stdafx.h @@ -220,7 +221,7 @@ MaxSpeed true true - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;%(AdditionalIncludeDirectories) DEBUGFAST;_SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded stdafx.h @@ -279,6 +280,7 @@ + diff --git a/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp b/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp index 086a2f794faf..712cebfd6440 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/FramebufferManager.cpp @@ -22,6 +22,7 @@ #include "PixelShaderCache.h" #include "VertexShaderCache.h" #include "TextureConverter.h" +#include "HW/Memmap.h" namespace DX9 { @@ -176,7 +177,7 @@ void XFBSource::DecodeToTexture(u32 xfbAddr, u32 fbWidth, u32 fbHeight) void FramebufferManager::CopyToRealXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma) { - u8* xfb_in_ram = Memory_GetPtr(xfbAddr); + u8* xfb_in_ram = Memory::GetPointer(xfbAddr); if (!xfb_in_ram) { WARN_LOG(VIDEO, "Tried to copy to invalid XFB address"); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Globals.h b/Source/Plugins/Plugin_VideoDX9/Src/Globals.h index f1c13d728c65..43f926309175 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Globals.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/Globals.h @@ -23,9 +23,5 @@ #include "main.h" #include "VideoCommon.h" -#include "pluginspecs_video.h" - -// A global plugin specification -extern PLUGIN_GLOBALS* globals; #endif // _GLOBALS_H_ \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp b/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp index e011e766aad1..bfaf21ec7eab 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/NativeVertexFormat.cpp @@ -27,6 +27,9 @@ #include "NativeVertexFormat.h" #include "VertexManager.h" +namespace DX9 +{ + class D3DVertexFormat : public NativeVertexFormat { LPDIRECT3DVERTEXDECLARATION9 d3d_decl; @@ -43,16 +46,11 @@ class D3DVertexFormat : public NativeVertexFormat #endif }; -namespace DX9 -{ - NativeVertexFormat* VertexManager::CreateNativeVertexFormat() { return new D3DVertexFormat(); } -} - void DX9::VertexManager::GetElements(NativeVertexFormat* format, D3DVERTEXELEMENT9** elems, int* num) { #if defined(_DEBUG) || defined(DEBUGFAST) @@ -191,3 +189,5 @@ void D3DVertexFormat::SetupVertexPointers() else ERROR_LOG(VIDEO, "invalid d3d decl"); } + +} // namespace DX9 diff --git a/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp index b298a2222332..234feace7fa6 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/PixelShaderCache.cpp @@ -36,6 +36,7 @@ #include "XFMemory.h" #include "ImageWrite.h" #include "Debugger.h" +#include "ConfigManager.h" namespace DX9 { @@ -274,7 +275,7 @@ void PixelShaderCache::Init() SETSTAT(stats.numPixelShadersAlive, 0); char cache_filename[MAX_PATH]; - sprintf(cache_filename, "%sdx9-%s-ps.cache", File::GetUserPath(D_SHADERCACHE_IDX), globals->unique_id); + sprintf(cache_filename, "%sdx9-%s-ps.cache", File::GetUserPath(D_SHADERCACHE_IDX), SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); PixelShaderCacheInserter inserter; g_ps_disk_cache.OpenAndRead(cache_filename, inserter); } @@ -418,21 +419,20 @@ bool PixelShaderCache::InsertByteCode(const PIXELSHADERUID &uid, const u8 *bytec return true; } -} // namespace DX9 - - -void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) +void Renderer::SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { float f[4] = { f1, f2, f3, f4 }; DX9::D3D::dev->SetPixelShaderConstantF(const_number, f, 1); } -void SetPSConstant4fv(unsigned int const_number, const float *f) +void Renderer::SetPSConstant4fv(unsigned int const_number, const float *f) { DX9::D3D::dev->SetPixelShaderConstantF(const_number, f, 1); } -void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f) +void Renderer::SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f) { DX9::D3D::dev->SetPixelShaderConstantF(const_number, f, count); } + +} // namespace DX9 diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp index bf4d29e26184..08b64ac09ed0 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.cpp @@ -50,6 +50,7 @@ #include "TextureConverter.h" #include "DLCache.h" #include "Debugger.h" +#include "Core.h" namespace DX9 { @@ -256,7 +257,7 @@ Renderer::Renderer() // Multisample Anti-aliasing hasn't been implemented yet use supersamling instead int backbuffer_ms_mode = 0; - g_VideoInitialize.pGetWindowSize(x, y, w_temp, h_temp); + Core::Callback_VideoGetWindowSize(x, y, w_temp, h_temp); for (fullScreenRes = 0; fullScreenRes < (int)D3D::GetAdapter(g_ActiveConfig.iAdapter).resolutions.size(); fullScreenRes++) { @@ -433,7 +434,7 @@ void Renderer::SetWindowSize(int width, int height) // Scale the window size by the EFB scale. CalculateTargetScale(width, height, width, height); - g_VideoInitialize.pRequestWindowSize(width, height); + Core::Callback_VideoRequestWindowSize(width, height); } bool Renderer::SetScissorRect() @@ -920,7 +921,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons { if (g_bSkipCurrentFrame || (!XFBWrited && (!g_ActiveConfig.bUseXFB || !g_ActiveConfig.bUseRealXFB)) || !fbWidth || !fbHeight) { - g_VideoInitialize.pCopiedToXFB(false); + Core::Callback_VideoCopiedToXFB(false); return; } // this function is called after the XFB field is changed, not after @@ -932,7 +933,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount); if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB) { - g_VideoInitialize.pCopiedToXFB(false); + Core::Callback_VideoCopiedToXFB(false); return; } @@ -1256,7 +1257,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons // Renderer::SetZBufferRender(); // SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget, // GetTargetWidth(), GetTargetHeight()); - g_VideoInitialize.pCopiedToXFB(XFBWrited || (g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB)); + Core::Callback_VideoCopiedToXFB(XFBWrited || (g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB)); XFBWrited = false; } diff --git a/Source/Plugins/Plugin_VideoDX9/Src/Render.h b/Source/Plugins/Plugin_VideoDX9/Src/Render.h index bd2c65bac4e8..5121a1992bc1 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/Render.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/Render.h @@ -48,6 +48,15 @@ class Renderer : public ::Renderer static bool CheckForResize(); static void SetWindowSize(int width, int height); + + void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4); + void SetPSConstant4fv(unsigned int const_number, const float *f); + void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f); + + void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4); + void SetVSConstant4fv(unsigned int const_number, const float *f); + void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f); + void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f); }; } // namespace DX9 diff --git a/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp b/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp index a0619270a07f..24072265938e 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/TextureConverter.cpp @@ -31,6 +31,7 @@ #include "TextureCache.h" #include "Math.h" #include "FileUtil.h" +#include "HW/Memmap.h" namespace DX9 { @@ -339,7 +340,7 @@ void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyf if (!texconv_shader) return; - u8 *dest_ptr = Memory_GetPtr(address); + u8 *dest_ptr = Memory::GetPointer(address); LPDIRECT3DTEXTURE9 source_texture = bFromZBuffer ? FramebufferManager::GetEFBDepthTexture() : FramebufferManager::GetEFBColorTexture(); int width = (source.right - source.left) >> bScaleByHalf; @@ -408,7 +409,7 @@ u64 EncodeToRamFromTexture(u32 address,LPDIRECT3DTEXTURE9 source_texture, u32 So if (!texconv_shader) return 0; - u8 *dest_ptr = Memory_GetPtr(address); + u8 *dest_ptr = Memory::GetPointer(address); int width = (source.right - source.left) >> bScaleByHalf; int height = (source.bottom - source.top) >> bScaleByHalf; @@ -480,7 +481,7 @@ void EncodeToRamYUYV(LPDIRECT3DTEXTURE9 srcTexture, const TargetRectangle& sourc // Should be scale free. void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, LPDIRECT3DTEXTURE9 destTexture) { - u8* srcAddr = Memory_GetPtr(xfbAddr); + u8* srcAddr = Memory::GetPointer(xfbAddr); if (!srcAddr) { WARN_LOG(VIDEO, "Tried to decode from invalid memory address"); diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp index ea77072e7ace..b7bf14afef2a 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/VertexShaderCache.cpp @@ -31,6 +31,7 @@ #include "BPMemory.h" #include "XFMemory.h" #include "Debugger.h" +#include "ConfigManager.h" namespace DX9 { @@ -146,7 +147,7 @@ void VertexShaderCache::Init() SETSTAT(stats.numVertexShadersAlive, 0); char cache_filename[MAX_PATH]; - sprintf(cache_filename, "%sdx9-%s-vs.cache", File::GetUserPath(D_SHADERCACHE_IDX), globals->unique_id); + sprintf(cache_filename, "%sdx9-%s-vs.cache", File::GetUserPath(D_SHADERCACHE_IDX), SConfig::GetInstance().m_LocalCoreStartupParameter.m_strUniqueID.c_str()); VertexShaderCacheInserter inserter; g_vs_disk_cache.OpenAndRead(cache_filename, inserter); } @@ -246,21 +247,18 @@ bool VertexShaderCache::InsertByteCode(const VERTEXSHADERUID &uid, const u8 *byt return false; } -} // namespace DX9 - - -void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) +void Renderer::SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { const float f[4] = { f1, f2, f3, f4 }; DX9::D3D::dev->SetVertexShaderConstantF(const_number, f, 1); } -void SetVSConstant4fv(unsigned int const_number, const float *f) +void Renderer::SetVSConstant4fv(unsigned int const_number, const float *f) { DX9::D3D::dev->SetVertexShaderConstantF(const_number, f, 1); } -void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f) +void Renderer::SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f) { float buf[4*C_VENVCONST_END]; for (unsigned int i = 0; i < count; i++) @@ -273,7 +271,9 @@ void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const DX9::D3D::dev->SetVertexShaderConstantF(const_number, buf, count); } -void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f) +void Renderer::SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f) { DX9::D3D::dev->SetVertexShaderConstantF(const_number, f, count); } + +} // namespace DX9 diff --git a/Source/Plugins/Plugin_VideoDX9/Src/VideoBackend.h b/Source/Plugins/Plugin_VideoDX9/Src/VideoBackend.h new file mode 100644 index 000000000000..05c21952b6ca --- /dev/null +++ b/Source/Plugins/Plugin_VideoDX9/Src/VideoBackend.h @@ -0,0 +1,27 @@ + +#ifndef DX9_VIDEO_BACKEND_H_ +#define DX9_VIDEO_BACKEND_H_ + +#include "VideoBackendBase.h" + +namespace DX9 +{ + +class VideoBackend : public VideoBackendHLE +{ + void Initialize(); + void Shutdown(); + + std::string GetName(); + + void Video_Prepare(); + + void ShowConfig(void* parent); + + void UpdateFPSDisplay(const char*); + unsigned int PeekMessages(); +}; + +} + +#endif diff --git a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp index 368a4ff92566..34bb34c8cc3b 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoDX9/Src/main.cpp @@ -53,84 +53,20 @@ #include "render.h" #include "DLCache.h" #include "IniFile.h" +#include "Core.h" -HINSTANCE g_hInstance = NULL; +#include "ConfigManager.h" +#include "VideoBackend.h" -wxLocale *InitLanguageSupport() +namespace DX9 { - wxLocale *m_locale; - unsigned int language = 0; - IniFile ini; - ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); - ini.Get("Interface", "Language", &language, wxLANGUAGE_DEFAULT); - - // Load language if possible, fall back to system default otherwise - if(wxLocale::IsAvailable(language)) - { - m_locale = new wxLocale(language); - - m_locale->AddCatalogLookupPathPrefix(wxT("Languages")); - - m_locale->AddCatalog(wxT("dolphin-emu")); - - if(!m_locale->IsOk()) - { - PanicAlertT("Error loading selected language. Falling back to system default."); - delete m_locale; - m_locale = new wxLocale(wxLANGUAGE_DEFAULT); - } - } - else - { - PanicAlertT("The selected language is not supported by your system. Falling back to system default."); - m_locale = new wxLocale(wxLANGUAGE_DEFAULT); - } - return m_locale; -} - - -// This is used for the functions right below here which use wxwidgets -WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); - -void *DllDebugger(void *_hParent, bool Show) +void*& VideoWindowHandle() { - return new GFXDebuggerPanel((wxWindow*)_hParent); + return SConfig::GetInstance().m_LocalCoreStartupParameter.hMainWindow; } -class wxDLLApp : public wxApp -{ - bool OnInit() - { - return true; - } -}; -IMPLEMENT_APP_NO_MAIN(wxDLLApp) -WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); - -BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved) -{ - static wxLocale *m_locale; - switch (dwReason) - { - case DLL_PROCESS_ATTACH: - { - wxSetInstance((HINSTANCE)hinstDLL); - wxInitialize(); - m_locale = InitLanguageSupport(); - } - break; - case DLL_PROCESS_DETACH: - wxUninitialize(); - delete m_locale; - break; - } - - g_hInstance = hinstDLL; - return TRUE; -} - -unsigned int Callback_PeekMessages() +unsigned int VideoBackend::PeekMessages() { MSG msg; while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) @@ -143,36 +79,29 @@ unsigned int Callback_PeekMessages() return TRUE; } - -void UpdateFPSDisplay(const char *text) +void VideoBackend::UpdateFPSDisplay(const char *text) { TCHAR temp[512]; swprintf_s(temp, sizeof(temp)/sizeof(TCHAR), _T("%hs | DX9 | %hs"), svn_rev_str, text); SetWindowText(EmuWindow::GetWnd(), temp); } -void GetDllInfo(PLUGIN_INFO* _PluginInfo) -{ - _PluginInfo->Version = 0x0100; - _PluginInfo->Type = PLUGIN_TYPE_VIDEO; -#ifdef DEBUGFAST - sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D9 (DebugFast)"); -#elif defined _DEBUG - sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D9 (Debug)"); -#else - sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D9"); -#endif -} - -void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) +//void GetDllInfo(PLUGIN_INFO* _PluginInfo) +//{ +// _PluginInfo->Version = 0x0100; +// //_PluginInfo->Type = PLUGIN_TYPE_VIDEO; +//#ifdef DEBUGFAST +// sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D9 (DebugFast)"); +//#elif defined _DEBUG +// sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D9 (Debug)"); +//#else +// sprintf_s(_PluginInfo->Name, 100, "Dolphin Direct3D9"); +//#endif +//} + +std::string VideoBackend::GetName() { - globals = _pPluginGlobals; - LogManager::SetInstance((LogManager*)globals->logManager); -} - -void DllAbout(HWND _hParent) -{ - //DialogBox(g_hInstance,(LPCTSTR)IDD_ABOUT,_hParent,(DLGPROC)AboutProc); + return "Direct3D9"; } void InitBackendInfo() @@ -190,7 +119,7 @@ void InitBackendInfo() g_Config.backend_info.bSupportsPixelLighting = C_PLIGHTS + 40 <= maxConstants && C_PMATERIALS + 4 <= maxConstants; } -void DllConfig(void *_hParent) +void VideoBackend::ShowConfig(void* parent) { #if defined(HAVE_WX) && HAVE_WX InitBackendInfo(); @@ -212,7 +141,7 @@ void DllConfig(void *_hParent) } - VideoConfigDiag *const diag = new VideoConfigDiag((wxWindow*)_hParent, _trans("Direct3D9"), "gfx_dx9"); + VideoConfigDiag *const diag = new VideoConfigDiag((wxWindow*)parent, _trans("Direct3D9"), "gfx_dx9"); diag->ShowModal(); diag->Destroy(); @@ -220,23 +149,20 @@ void DllConfig(void *_hParent) #endif } -void Initialize(void *init) +void VideoBackend::Initialize() { InitBackendInfo(); frameCount = 0; - SVideoInitialize *_pVideoInitialize = (SVideoInitialize*)init; - // Create a shortcut to _pVideoInitialize that can also update it - g_VideoInitialize = *(_pVideoInitialize); InitXFBConvTables(); g_Config.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_dx9.ini").c_str()); - g_Config.GameIniLoad(globals->game_ini); + g_Config.GameIniLoad(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strGameIni.c_str()); UpdateProjectionHack(g_Config.iPhackvalue, g_Config.sPhackvalue); // DX9 projection hack could be disabled by commenting out this line UpdateActiveConfig(); - g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, _T("Loading - Please wait.")); - if (g_VideoInitialize.pWindowHandle == NULL) + VideoWindowHandle() = (void*)EmuWindow::Create((HWND)VideoWindowHandle(), GetModuleHandle(0), _T("Loading - Please wait.")); + if (VideoWindowHandle() == NULL) { ERROR_LOG(VIDEO, "An error has occurred while trying to create the window."); return; @@ -247,20 +173,11 @@ void Initialize(void *init) return; } - g_VideoInitialize.pPeekMessages = &Callback_PeekMessages; - g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay; - - _pVideoInitialize->pPeekMessages = g_VideoInitialize.pPeekMessages; - _pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay; - - // Now the window handle is written - _pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle; - OSD::AddMessage("Dolphin Direct3D9 Video Plugin.", 5000); s_PluginInitialized = true; } -void Video_Prepare() +void VideoBackend::Video_Prepare() { // Better be safe... s_efbAccessRequested = FALSE; @@ -268,9 +185,9 @@ void Video_Prepare() s_swapRequested = FALSE; // internal interfaces - g_renderer = new DX9::Renderer; - g_texture_cache = new DX9::TextureCache; - g_vertex_manager = new DX9::VertexManager; + g_renderer = new Renderer; + g_texture_cache = new TextureCache; + g_vertex_manager = new VertexManager; // VideoCommon BPInit(); Fifo_Init(); @@ -283,10 +200,10 @@ void Video_Prepare() DLCache::Init(); // Notify the core that the video plugin is ready - g_VideoInitialize.pCoreMessage(WM_USER_CREATE); + Core::Callback_CoreMessage(WM_USER_CREATE); } -void Shutdown() +void VideoBackend::Shutdown() { s_PluginInitialized = false; @@ -304,11 +221,13 @@ void Shutdown() VertexLoaderManager::Shutdown(); // internal interfaces - DX9::PixelShaderCache::Shutdown(); - DX9::VertexShaderCache::Shutdown(); + PixelShaderCache::Shutdown(); + VertexShaderCache::Shutdown(); delete g_vertex_manager; delete g_texture_cache; delete g_renderer; - DX9::D3D::Shutdown(); + D3D::Shutdown(); EmuWindow::Close(); } + +} diff --git a/Source/Plugins/Plugin_VideoDX9/Src/main.h b/Source/Plugins/Plugin_VideoDX9/Src/main.h index 1a0ee15e9bc0..069f72e9513b 100644 --- a/Source/Plugins/Plugin_VideoDX9/Src/main.h +++ b/Source/Plugins/Plugin_VideoDX9/Src/main.h @@ -18,10 +18,10 @@ #ifndef MAIN_H #define MAIN_H -#include "PluginSpecs_Video.h" +#include + +#include "VideoBackend.h" #include "Render.h" #include "MainBase.h" -extern SVideoInitialize g_VideoInitialize; - #endif diff --git a/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcproj b/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcproj index 1f9e4d4a9774..69dd902de3fd 100644 --- a/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcproj +++ b/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcproj @@ -2,7 +2,7 @@ - @@ -117,9 +105,6 @@ - @@ -128,7 +113,7 @@ Name="Release|x64" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -165,7 +150,7 @@ FavorSizeOrSpeed="1" OmitFramePointers="false" WholeProgramOptimization="true" - AdditionalIncludeDirectories="../../PluginSpecs;../../Core/Common/Src;../../Core/InputCommon/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;./Src;./Src/Windows;../../../Externals;..\..\..\Externals\libjpeg;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\Glew\include" + AdditionalIncludeDirectories="../../PluginSpecs;../../Core/Common/Src;../../Core/Core/Src;../../Core/InputCommon/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;./Src;./Src/Windows;../../../Externals;..\..\..\Externals\libjpeg;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\Glew\include" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0" StringPooling="true" ExceptionHandling="1" @@ -199,27 +184,13 @@ Name="VCPreLinkEventTool" /> - @@ -229,9 +200,6 @@ - @@ -240,7 +208,7 @@ Name="Debug|Win32" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -270,7 +238,7 @@ - @@ -327,9 +282,6 @@ - @@ -338,7 +290,7 @@ Name="Debug|x64" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -368,7 +320,7 @@ - @@ -426,9 +364,6 @@ - @@ -437,7 +372,7 @@ Name="DebugFast|Win32" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -472,7 +407,7 @@ EnableIntrinsicFunctions="true" OmitFramePointers="true" WholeProgramOptimization="false" - AdditionalIncludeDirectories="../../PluginSpecs;../../Core/Common/Src;../../Core/InputCommon/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;./Src;./Src/Windows;../../../Externals;..\..\..\Externals\libjpeg;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\Glew\include" + AdditionalIncludeDirectories="../../PluginSpecs;../../Core/Common/Src;../../Core/Core/Src;../../Core/InputCommon/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;./Src;./Src/Windows;../../../Externals;..\..\..\Externals\libjpeg;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\Glew\include" PreprocessorDefinitions="_WIN32;WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;DEBUGFAST" StringPooling="true" RuntimeLibrary="0" @@ -504,27 +439,13 @@ Name="VCPreLinkEventTool" /> - @@ -534,9 +455,6 @@ - @@ -545,7 +463,7 @@ Name="DebugFast|x64" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" UseOfMFC="0" ATLMinimizesCRunTimeLibraryUsage="false" @@ -581,7 +499,7 @@ FavorSizeOrSpeed="1" OmitFramePointers="false" WholeProgramOptimization="false" - AdditionalIncludeDirectories="../../PluginSpecs;../../Core/Common/Src;../../Core/InputCommon/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;./Src;./Src/Windows;../../../Externals;..\..\..\Externals\libjpeg;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\Glew\include" + AdditionalIncludeDirectories="../../PluginSpecs;../../Core/Common/Src;../../Core/Core/Src;../../Core/InputCommon/Src;../../Core/VideoCommon/Src;../../Core/VideoUICommon/Src;./Src;./Src/Windows;../../../Externals;..\..\..\Externals\libjpeg;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\Glew\include" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0;DEBUGFAST" StringPooling="true" ExceptionHandling="1" @@ -614,26 +532,13 @@ Name="VCPreLinkEventTool" /> - @@ -643,9 +548,6 @@ - diff --git a/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcxproj b/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcxproj index 2a1a478cc565..13d003d1c892 100644 --- a/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcxproj +++ b/Source/Plugins/Plugin_VideoOGL/Plugin_VideoOGL.vcxproj @@ -29,38 +29,39 @@ {1909CD2D-1707-456F-86CA-0DF42A727C99} Plugin_VideoOGL + VideoOGL - DynamicLibrary + StaticLibrary true Unicode - DynamicLibrary + StaticLibrary true Unicode - DynamicLibrary + StaticLibrary false true Unicode - DynamicLibrary + StaticLibrary false true Unicode - DynamicLibrary + StaticLibrary false true Unicode - DynamicLibrary + StaticLibrary false true Unicode @@ -131,7 +132,7 @@ Level3 Disabled - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\GLew\include;..\..\..\Externals + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\GLew\include;..\..\..\Externals _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreadedDebug stdafx.h @@ -143,12 +144,16 @@ ..\..\..\Externals\GLew;..\..\..\Externals\Cg;%(AdditionalLibraryDirectories) ..\..\..\Binary\$(PlatformName)\Plugins\$(TargetName)$(TargetExt) + + cg.lib;cgGL.lib;opengl32.lib;glew32s.lib;glu32.lib + ..\..\..\Externals\Cg;..\..\..\Externals\GLew;%(AdditionalLibraryDirectories) + Level3 Disabled - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\GLew\include;..\..\..\Externals + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\GLew\include;..\..\..\Externals _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreadedDebug stdafx.h @@ -160,6 +165,10 @@ ..\..\..\Externals\GLew;..\..\..\Externals\Cg64;%(AdditionalLibraryDirectories) ..\..\..\Binary\$(PlatformName)\Plugins\$(TargetName)$(TargetExt) + + cg.lib;cgGL.lib;opengl32.lib;glew64s.lib;glu32.lib + ..\..\..\Externals\Cg64;..\..\..\Externals\GLew;%(AdditionalLibraryDirectories) + @@ -167,7 +176,7 @@ MaxSpeed true true - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\GLew\include;..\..\..\Externals + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\GLew\include;..\..\..\Externals _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded stdafx.h @@ -181,6 +190,10 @@ ..\..\..\Externals\GLew;..\..\..\Externals\Cg;%(AdditionalLibraryDirectories) ..\..\..\Binary\$(PlatformName)\Plugins\$(TargetName)$(TargetExt) + + cg.lib;cgGL.lib;opengl32.lib;glew32s.lib;glu32.lib + ..\..\..\Externals\Cg;..\..\..\Externals\GLew;%(AdditionalLibraryDirectories) + @@ -202,6 +215,10 @@ ..\..\..\Externals\GLew;..\..\..\Externals\Cg;%(AdditionalLibraryDirectories) ..\..\..\Binary\$(PlatformName)\Plugins\$(TargetName)$(TargetExt) + + cg.lib;cgGL.lib;opengl32.lib;glew32s.lib;glu32.lib + ..\..\..\Externals\Cg;..\..\..\Externals\GLew;%(AdditionalLibraryDirectories) + @@ -209,7 +226,7 @@ MaxSpeed true true - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\GLew\include;..\..\..\Externals + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\wxWidgets\include;..\..\..\Externals\GLew\include;..\..\..\Externals _SECURE_SCL=0;%(PreprocessorDefinitions) MultiThreaded stdafx.h @@ -223,6 +240,10 @@ ..\..\..\Externals\GLew;..\..\..\Externals\Cg64;%(AdditionalLibraryDirectories) ..\..\..\Binary\$(PlatformName)\Plugins\$(TargetName)$(TargetExt) + + cg.lib;cgGL.lib;opengl32.lib;glew64s.lib;glu32.lib + ..\..\..\Externals\Cg64;..\..\..\Externals\GLew;%(AdditionalLibraryDirectories) + @@ -244,6 +265,10 @@ ..\..\..\Externals\GLew;..\..\..\Externals\Cg64;%(AdditionalLibraryDirectories) ..\..\..\Binary\$(PlatformName)\Plugins\$(TargetName)$(TargetExt) + + cg.lib;cgGL.lib;opengl32.lib;glew64s.lib;glu32.lib + ..\..\..\Externals\Cg64;..\..\..\Externals\GLew;%(AdditionalLibraryDirectories) + @@ -282,6 +307,7 @@ + diff --git a/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.cpp b/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.cpp index 233b01bfa30c..0e37c3adb67b 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/FramebufferManager.cpp @@ -20,8 +20,7 @@ #include "TextureConverter.h" #include "Render.h" - - +#include "HW/Memmap.h" namespace OGL { @@ -272,7 +271,7 @@ GLuint FramebufferManager::GetEFBDepthTexture(const EFBRectangle& sourceRc) void FramebufferManager::CopyToRealXFB(u32 xfbAddr, u32 fbWidth, u32 fbHeight, const EFBRectangle& sourceRc,float Gamma) { - u8* xfb_in_ram = Memory_GetPtr(xfbAddr); + u8* xfb_in_ram = Memory::GetPointer(xfbAddr); if (!xfb_in_ram) { WARN_LOG(VIDEO, "Tried to copy to invalid XFB address"); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp index 936b27c153df..58a8078d9436 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp @@ -19,6 +19,10 @@ #include "VideoConfig.h" #include "IniFile.h" #include "Setup.h" +#include "Core.h" +#include "Host.h" +#include "VideoBackend.h" +#include "ConfigManager.h" #include "Render.h" #include "VertexShaderManager.h" @@ -29,7 +33,6 @@ #include "EmuWindow.h" static HDC hDC = NULL; // Private GDI Device Context static HGLRC hRC = NULL; // Permanent Rendering Context -extern HINSTANCE g_hInstance; #else GLWindow GLWin; #endif @@ -79,8 +82,16 @@ void OpenGL_SetWindowText(const char *text) #endif } +static void*& VideoWindowHandle() +{ + return SConfig::GetInstance().m_LocalCoreStartupParameter.hMainWindow; +} + +namespace OGL +{ + // Draw messages on top of the screen -unsigned int Callback_PeekMessages() +unsigned int VideoBackend::PeekMessages() { #ifdef _WIN32 // TODO: peekmessage @@ -99,13 +110,15 @@ unsigned int Callback_PeekMessages() } // Show the current FPS -void UpdateFPSDisplay(const char *text) +void VideoBackend::UpdateFPSDisplay(const char *text) { char temp[100]; snprintf(temp, sizeof temp, "%s | OpenGL | %s", svn_rev_str, text); OpenGL_SetWindowText(temp); } +} + #if defined(HAVE_X11) && HAVE_X11 void XEventThread(); @@ -291,7 +304,7 @@ void XEventThread() break; case ClientMessage: if ((unsigned long) event.xclient.data.l[0] == XInternAtom(GLWin.evdpy, "WM_DELETE_WINDOW", False)) - g_VideoInitialize.pCoreMessage(WM_USER_STOP); + Core::Callback_CoreMessage(WM_USER_STOP); if ((unsigned long) event.xclient.data.l[0] == XInternAtom(GLWin.evdpy, "RESIZE", False)) XMoveResizeWindow(GLWin.evdpy, GLWin.win, event.xclient.data.l[1], event.xclient.data.l[2], event.xclient.data.l[3], event.xclient.data.l[4]); @@ -307,20 +320,17 @@ void XEventThread() // Create rendering window. // Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize() -bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight) +bool OpenGL_Create(int _iwidth, int _iheight) { int _tx, _ty, _twidth, _theight; - g_VideoInitialize.pGetWindowSize(_tx, _ty, _twidth, _theight); + Core::Callback_VideoGetWindowSize(_tx, _ty, _twidth, _theight); // Control window size and picture scaling s_backbuffer_width = _twidth; s_backbuffer_height = _theight; - g_VideoInitialize.pPeekMessages = &Callback_PeekMessages; - g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay; - #if defined(USE_WX) && USE_WX - GLWin.panel = (wxPanel *)g_VideoInitialize.pWindowHandle; + GLWin.panel = (wxPanel *)VideoWindowHandle(); GLWin.glCanvas = new wxGLCanvas(GLWin.panel, wxID_ANY, NULL, wxPoint(0, 0), wxSize(_twidth, _theight)); GLWin.glCanvas->Show(true); @@ -333,7 +343,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight initWithAttributes: attr]; if (fmt == nil) { printf("failed to create pixel format\n"); - return false; + return NULL; } GLWin.cocoaCtx = [[NSOpenGLContext alloc] @@ -341,7 +351,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight [fmt release]; if (GLWin.cocoaCtx == nil) { printf("failed to create context\n"); - return false; + return NULL; } GLWin.cocoaWin = [[NSWindow alloc] @@ -353,10 +363,10 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight [GLWin.cocoaCtx setView: [GLWin.cocoaWin contentView]]; #elif defined(_WIN32) - g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, _T("Please wait...")); - if (g_VideoInitialize.pWindowHandle == NULL) + VideoWindowHandle() = (void*)EmuWindow::Create((HWND)VideoWindowHandle(), GetModuleHandle(0), _T("Please wait...")); + if (VideoWindowHandle() == NULL) { - g_VideoInitialize.pSysMessage("failed to create window"); + Host_SysMessage("failed to create window"); return false; } @@ -438,7 +448,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight GLWin.dpy = XOpenDisplay(0); GLWin.evdpy = XOpenDisplay(0); - GLWin.parent = (Window)g_VideoInitialize.pWindowHandle; + GLWin.parent = (Window)VideoWindowHandle(); GLWin.screen = DefaultScreen(GLWin.dpy); if (GLWin.parent == 0) GLWin.parent = RootWindow(GLWin.dpy, GLWin.screen); @@ -482,9 +492,9 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _iwidth, int _iheight GLWin.height = _theight; CreateXWindow(); - g_VideoInitialize.pWindowHandle = (void *)GLWin.win; + VideoWindowHandle() = (void *)GLWin.win; #endif - return true; + return false; } bool OpenGL_MakeCurrent() @@ -498,7 +508,7 @@ bool OpenGL_MakeCurrent() return wglMakeCurrent(hDC,hRC) ? true : false; #elif defined(HAVE_X11) && HAVE_X11 #if defined(HAVE_WX) && (HAVE_WX) - g_VideoInitialize.pGetWindowSize(GLWin.x, GLWin.y, (int&)GLWin.width, (int&)GLWin.height); + Core::Callback_VideoGetWindowSize(GLWin.x, GLWin.y, (int&)GLWin.width, (int&)GLWin.height); XMoveResizeWindow(GLWin.dpy, GLWin.win, GLWin.x, GLWin.y, GLWin.width, GLWin.height); #endif return glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h index ecb4123924b2..735b0f47317e 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.h @@ -21,7 +21,6 @@ #include "VideoConfig.h" #include "MathUtil.h" #include "Thread.h" -#include "pluginspecs_video.h" #ifdef _WIN32 #define GLEW_STATIC @@ -85,7 +84,7 @@ extern GLWindow GLWin; // Public OpenGL util // Initialization / upkeep -bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height); +bool OpenGL_Create(int _width, int _height); void OpenGL_Shutdown(); void OpenGL_Update(); bool OpenGL_MakeCurrent(); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h index e0d86e702abe..3d26e17b7549 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Globals.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Globals.h @@ -22,9 +22,5 @@ #include "VideoConfig.h" #include "VideoCommon.h" -#include "pluginspecs_video.h" - -// A global plugin specification -extern PLUGIN_GLOBALS* globals; #endif // _GLOBALS_H_ diff --git a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp index 32c53ac6352d..29a5c7fb4609 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/PixelShaderCache.cpp @@ -324,7 +324,6 @@ void PixelShaderCache::DisableShader() } } - //bind a program if is diferent from the binded oone void PixelShaderCache::SetCurrentShader(GLuint Shader) { @@ -341,22 +340,21 @@ void PixelShaderCache::SetCurrentShader(GLuint Shader) } } -} // namespace OGL - - -void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) +void Renderer::SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { float f[4] = { f1, f2, f3, f4 }; glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f); } -void SetPSConstant4fv(unsigned int const_number, const float *f) +void Renderer::SetPSConstant4fv(unsigned int const_number, const float *f) { glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number, f); } -void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f) +void Renderer::SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f) { for (unsigned int i = 0; i < count; i++,f+=4) glProgramEnvParameter4fvARB(GL_FRAGMENT_PROGRAM_ARB, const_number + i, f); } + +} // namespace OGL diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp index cbf825a4e195..4ae7ea9426a6 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.cpp @@ -57,6 +57,7 @@ #include "FramebufferManager.h" #include "Fifo.h" #include "Debugger.h" +#include "Core.h" #include "main.h" // Local #ifdef _WIN32 @@ -962,7 +963,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons { if (g_bSkipCurrentFrame || (!XFBWrited && (!g_ActiveConfig.bUseXFB || !g_ActiveConfig.bUseRealXFB)) || !fbWidth || !fbHeight) { - g_VideoInitialize.pCopiedToXFB(false); + Core::Callback_VideoCopiedToXFB(false); return; } // this function is called after the XFB field is changed, not after @@ -974,7 +975,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons const XFBSourceBase* const* xfbSourceList = FramebufferManager::GetXFBSource(xfbAddr, fbWidth, fbHeight, xfbCount); if ((!xfbSourceList || xfbCount == 0) && g_ActiveConfig.bUseXFB && !g_ActiveConfig.bUseRealXFB) { - g_VideoInitialize.pCopiedToXFB(false); + Core::Callback_VideoCopiedToXFB(false); return; } @@ -1365,7 +1366,7 @@ void Renderer::Swap(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight,cons // Renderer::SetZBufferRender(); // SaveTexture("tex.tga", GL_TEXTURE_RECTANGLE_ARB, s_FakeZTarget, // GetTargetWidth(), GetTargetHeight()); - g_VideoInitialize.pCopiedToXFB(XFBWrited || (g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB)); + Core::Callback_VideoCopiedToXFB(XFBWrited || (g_ActiveConfig.bUseXFB && g_ActiveConfig.bUseRealXFB)); XFBWrited = false; } @@ -1485,6 +1486,9 @@ void Renderer::FlipImageData(u8 *data, int w, int h) } +// TODO: remove +extern bool g_aspect_wide; + #if defined(HAVE_WX) && HAVE_WX void TakeScreenshot(ScrStrct* threadStruct) { @@ -1495,7 +1499,7 @@ void TakeScreenshot(ScrStrct* threadStruct) // Handle aspect ratio for the final ScrStrct to look exactly like what's on screen. if (g_ActiveConfig.iAspectRatio != ASPECT_STRETCH) { - bool use16_9 = g_VideoInitialize.bAutoAspectIs16_9; + bool use16_9 = g_aspect_wide; // Check for force-settings and override. if (g_ActiveConfig.iAspectRatio == ASPECT_FORCE_16_9) @@ -1589,7 +1593,7 @@ void Renderer::SetWindowSize(int width, int height) // Scale the window size by the EFB scale. CalculateTargetScale(width, height, width, height); - g_VideoInitialize.pRequestWindowSize(width, height); + Core::Callback_VideoRequestWindowSize(width, height); } } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/Render.h b/Source/Plugins/Plugin_VideoOGL/Src/Render.h index 256c7c0873c1..a78d82968cba 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/Render.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/Render.h @@ -50,6 +50,15 @@ class Renderer : public ::Renderer bool SaveScreenshot(const std::string &filename, const TargetRectangle &rc); void SetWindowSize(int width, int height); + + void SetPSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4); + void SetPSConstant4fv(unsigned int const_number, const float *f); + void SetMultiPSConstant4fv(unsigned int const_number, unsigned int count, const float *f); + + void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4); + void SetVSConstant4fv(unsigned int const_number, const float *f); + void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f); + void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f); }; } diff --git a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp index 1442df28f881..98bc25d55dcf 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/TextureConverter.cpp @@ -18,6 +18,8 @@ // Fast image conversion using OpenGL shaders. // This kind of stuff would be a LOT nicer with OpenCL. +#include + #include "TextureConverter.h" #include "TextureConversionShader.h" #include "TextureCache.h" @@ -28,8 +30,8 @@ #include "VideoConfig.h" #include "ImageWrite.h" #include "Render.h" -#include #include "FileUtil.h" +#include "HW/Memmap.h" namespace OGL { @@ -265,7 +267,7 @@ void EncodeToRam(u32 address, bool bFromZBuffer, bool bIsIntensityFmt, u32 copyf if (texconv_shader.glprogid == 0) return; - u8 *dest_ptr = Memory_GetPtr(address); + u8 *dest_ptr = Memory::GetPointer(address); GLuint source_texture = bFromZBuffer ? FramebufferManager::ResolveAndGetDepthTarget(source) : FramebufferManager::ResolveAndGetRenderTarget(source); @@ -336,7 +338,7 @@ u64 EncodeToRamFromTexture(u32 address,GLuint source_texture, bool bFromZBuffer, if (texconv_shader.glprogid == 0) return 0; - u8 *dest_ptr = Memory_GetPtr(address); + u8 *dest_ptr = Memory::GetPointer(address); int width = (source.right - source.left) >> bScaleByHalf; int height = (source.bottom - source.top) >> bScaleByHalf; @@ -405,7 +407,7 @@ void EncodeToRamYUYV(GLuint srcTexture, const TargetRectangle& sourceRc, u8* des // Should be scale free. void DecodeToTexture(u32 xfbAddr, int srcWidth, int srcHeight, GLuint destTexture) { - u8* srcAddr = Memory_GetPtr(xfbAddr); + u8* srcAddr = Memory::GetPointer(xfbAddr); if (!srcAddr) { WARN_LOG(VIDEO, "Tried to decode from invalid memory address"); diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp index 3948e592de98..9924508f4094 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/VertexShaderCache.cpp @@ -210,19 +210,17 @@ void VertexShaderCache::SetCurrentShader(GLuint Shader) } } -} // namespace OGL - -void SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) +void Renderer::SetVSConstant4f(unsigned int const_number, float f1, float f2, float f3, float f4) { glProgramEnvParameter4fARB(GL_VERTEX_PROGRAM_ARB, const_number, f1, f2, f3, f4); } -void SetVSConstant4fv(unsigned int const_number, const float *f) +void Renderer::SetVSConstant4fv(unsigned int const_number, const float *f) { glProgramEnvParameter4fvARB(GL_VERTEX_PROGRAM_ARB, const_number, f); } -void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f) +void Renderer::SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const float *f) { if(GLEW_EXT_gpu_program_parameters) { @@ -235,7 +233,7 @@ void SetMultiVSConstant4fv(unsigned int const_number, unsigned int count, const } } -void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f) +void Renderer::SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const float *f) { if(GLEW_EXT_gpu_program_parameters) { @@ -262,3 +260,5 @@ void SetMultiVSConstant3fv(unsigned int const_number, unsigned int count, const } } } + +} // namespace OGL diff --git a/Source/Plugins/Plugin_VideoOGL/Src/VideoBackend.h b/Source/Plugins/Plugin_VideoOGL/Src/VideoBackend.h new file mode 100644 index 000000000000..c529c5863955 --- /dev/null +++ b/Source/Plugins/Plugin_VideoOGL/Src/VideoBackend.h @@ -0,0 +1,27 @@ + +#ifndef OGL_VIDEO_BACKEND_H_ +#define OGL_VIDEO_BACKEND_H_ + +#include "VideoBackendBase.h" + +namespace OGL +{ + +class VideoBackend : public VideoBackendHLE +{ + void Initialize(); + void Shutdown(); + + std::string GetName(); + + void Video_Prepare(); + + void ShowConfig(void* parent); + + void UpdateFPSDisplay(const char*); + unsigned int PeekMessages(); +}; + +} + +#endif diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp index b39540cc6a0e..51cb959aaf3b 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.cpp @@ -92,109 +92,21 @@ Make AA apply instantly during gameplay if possible #include "Setup.h" #include "DLCache.h" #include "FramebufferManager.h" +#include "Core.h" #include "VideoState.h" +#include "VideoBackend.h" +#include "ConfigManager.h" // Logging int GLScissorX, GLScissorY, GLScissorW, GLScissorH; -#ifdef _WIN32 -HINSTANCE g_hInstance; - -wxLocale *InitLanguageSupport() -{ - wxLocale *m_locale; - unsigned int language = 0; - - IniFile ini; - ini.Load(File::GetUserPath(F_DOLPHINCONFIG_IDX)); - ini.Get("Interface", "Language", &language, wxLANGUAGE_DEFAULT); - - // Load language if possible, fall back to system default otherwise - if(wxLocale::IsAvailable(language)) - { - m_locale = new wxLocale(language); - - m_locale->AddCatalogLookupPathPrefix(wxT("Languages")); - - m_locale->AddCatalog(wxT("dolphin-emu")); - - if(!m_locale->IsOk()) - { - PanicAlertT("Error loading selected language. Falling back to system default."); - delete m_locale; - m_locale = new wxLocale(wxLANGUAGE_DEFAULT); - } - } - else - { - PanicAlertT("The selected language is not supported by your system. Falling back to system default."); - m_locale = new wxLocale(wxLANGUAGE_DEFAULT); - } - return m_locale; -} - -class wxDLLApp : public wxApp -{ - bool OnInit() - { - return true; - } -}; -IMPLEMENT_APP_NO_MAIN(wxDLLApp) -WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); -// ------------------ - -BOOL APIENTRY DllMain(HINSTANCE hinstDLL, DWORD dwReason, LPVOID lpvReserved) +namespace OGL { - static wxLocale *m_locale; - switch (dwReason) - { - case DLL_PROCESS_ATTACH: - { - wxSetInstance((HINSTANCE)hinstDLL); - wxInitialize(); - m_locale = InitLanguageSupport(); - } - break; - - case DLL_PROCESS_DETACH: - wxUninitialize(); - delete m_locale; - break; - } - - g_hInstance = hinstDLL; - return TRUE; -} -#endif // _WIN32 - -void GetDllInfo(PLUGIN_INFO* _PluginInfo) -{ - _PluginInfo->Version = 0x0100; - _PluginInfo->Type = PLUGIN_TYPE_VIDEO; -#ifdef DEBUGFAST - sprintf(_PluginInfo->Name, "Dolphin OpenGL (DebugFast)"); -#elif defined _DEBUG - sprintf(_PluginInfo->Name, "Dolphin OpenGL (Debug)"); -#else - sprintf(_PluginInfo->Name, _trans("Dolphin OpenGL")); -#endif -} - -void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) -{ - globals = _pPluginGlobals; - LogManager::SetInstance((LogManager*)globals->logManager); -} -void *DllDebugger(void *_hParent, bool Show) +std::string VideoBackend::GetName() { -#if defined(HAVE_WX) && HAVE_WX - return new GFXDebuggerPanel((wxWindow *)_hParent); -#else - return NULL; -#endif + return "OpenGL"; } void GetShaders(std::vector &shaders) @@ -231,7 +143,7 @@ void InitBackendInfo() g_Config.backend_info.bSupportsPixelLighting = true; } -void DllConfig(void *_hParent) +void VideoBackend::ShowConfig(void *_hParent) { #if defined(HAVE_WX) && HAVE_WX InitBackendInfo(); @@ -249,18 +161,15 @@ void DllConfig(void *_hParent) #endif } -void Initialize(void *init) +void VideoBackend::Initialize() { InitBackendInfo(); frameCount = 0; - SVideoInitialize *_pVideoInitialize = (SVideoInitialize*)init; - // Create a shortcut to _pVideoInitialize that can also update it - g_VideoInitialize = *(_pVideoInitialize); InitXFBConvTables(); g_Config.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_opengl.ini").c_str()); - g_Config.GameIniLoad(globals->game_ini); + g_Config.GameIniLoad(SConfig::GetInstance().m_LocalCoreStartupParameter.m_strGameIni.c_str()); g_Config.UpdateProjectionHack(); #if defined _WIN32 @@ -269,25 +178,20 @@ void Initialize(void *init) #endif UpdateActiveConfig(); - if (!OpenGL_Create(g_VideoInitialize, 640, 480)) + if (!OpenGL_Create(640, 480)) { - g_VideoInitialize.pLog("Renderer::Create failed\n", TRUE); return; } - _pVideoInitialize->pPeekMessages = g_VideoInitialize.pPeekMessages; - _pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay; - - // Now the window handle is written - _pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle; - OSD::AddMessage("Dolphin OpenGL Video Plugin.", 5000); s_PluginInitialized = true; + + return; } // This is called after Initialize() from the Core // Run from the graphics thread -void Video_Prepare() +void VideoBackend::Video_Prepare() { OpenGL_MakeCurrent(); //if (!Renderer::Init()) { @@ -296,7 +200,7 @@ void Video_Prepare() // exit(1); //} - g_renderer = new OGL::Renderer; + g_renderer = new Renderer; s_efbAccessRequested = FALSE; s_FifoShuttingDown = FALSE; @@ -305,31 +209,31 @@ void Video_Prepare() CommandProcessor::Init(); PixelEngine::Init(); - g_texture_cache = new OGL::TextureCache; + g_texture_cache = new TextureCache; BPInit(); - g_vertex_manager = new OGL::VertexManager; + g_vertex_manager = new VertexManager; Fifo_Init(); // must be done before OpcodeDecoder_Init() OpcodeDecoder_Init(); - OGL::VertexShaderCache::Init(); + VertexShaderCache::Init(); VertexShaderManager::Init(); - OGL::PixelShaderCache::Init(); + PixelShaderCache::Init(); PixelShaderManager::Init(); - OGL::PostProcessing::Init(); + PostProcessing::Init(); GL_REPORT_ERRORD(); VertexLoaderManager::Init(); - OGL::TextureConverter::Init(); + TextureConverter::Init(); DLCache::Init(); // Notify the core that the video plugin is ready - g_VideoInitialize.pCoreMessage(WM_USER_CREATE); + Core::Callback_CoreMessage(WM_USER_CREATE); s_PluginInitialized = true; INFO_LOG(VIDEO, "Video plugin initialized."); } -void Shutdown() +void VideoBackend::Shutdown() { s_PluginInitialized = false; @@ -354,3 +258,5 @@ void Shutdown() delete g_renderer; OpenGL_Shutdown(); } + +} diff --git a/Source/Plugins/Plugin_VideoOGL/Src/main.h b/Source/Plugins/Plugin_VideoOGL/Src/main.h index 99f8928fa68c..1ee2175febce 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/main.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/main.h @@ -18,9 +18,6 @@ #ifndef _MAIN_H_ #define _MAIN_H_ -#include "pluginspecs_video.h" #include "MainBase.h" -extern SVideoInitialize g_VideoInitialize; - #endif // _MAIN_H_ diff --git a/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcproj b/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcproj index b926943c55cf..0116b887b29b 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcproj +++ b/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcproj @@ -2,7 +2,7 @@ - @@ -98,9 +82,6 @@ - @@ -109,7 +90,7 @@ Name="Debug|x64" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" CharacterSet="1" > - @@ -186,9 +150,6 @@ - @@ -197,7 +158,7 @@ Name="Release|Win32" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" CharacterSet="1" WholeProgramOptimization="1" > @@ -220,7 +181,7 @@ Name="VCCLCompilerTool" Optimization="2" EnableIntrinsicFunctions="true" - AdditionalIncludeDirectories="../../PluginSpecs;../../Core/Common/Src;../../Core/InputCommon/Src;../../Core/VideoCommon/Src;./Src;./Src/Windows;../../../Externals;..\..\..\Externals\libjpeg;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\Glew\include;..\..\..\Externals\CLRun\include" + AdditionalIncludeDirectories="../../PluginSpecs;../../Core/Common/Src;../../Core/Core/Src;../../Core/InputCommon/Src;../../Core/VideoCommon/Src;./Src;./Src/Windows;../../../Externals;..\..\..\Externals\libjpeg;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\Glew\include;..\..\..\Externals\CLRun\include" PreprocessorDefinitions="WIN32;_WINDOWS;_USRDLL;_WIN32;PLUGIN_VIDEOSOFTWARE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0" RuntimeLibrary="0" EnableFunctionLevelLinking="true" @@ -241,28 +202,11 @@ Name="VCPreLinkEventTool" /> - @@ -272,9 +216,6 @@ - @@ -283,7 +224,7 @@ Name="Release|x64" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" - ConfigurationType="2" + ConfigurationType="4" CharacterSet="1" WholeProgramOptimization="1" > @@ -308,7 +249,7 @@ AdditionalOptions="/MP" Optimization="2" EnableIntrinsicFunctions="true" - AdditionalIncludeDirectories="../../PluginSpecs;../../Core/Common/Src;../../Core/InputCommon/Src;../../Core/VideoCommon/Src;./Src;./Src/Windows;../../../Externals;..\..\..\Externals\libjpeg;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\Glew\include;..\..\..\Externals\CLRun\include" + AdditionalIncludeDirectories="../../PluginSpecs;../../Core/Common/Src;../../Core/Core/Src;../../Core/InputCommon/Src;../../Core/VideoCommon/Src;./Src;./Src/Windows;../../../Externals;..\..\..\Externals\libjpeg;..\..\..\Externals\wxWidgets\Include;..\..\..\Externals\wxWidgets\Include\msvc;..\..\..\Externals\Glew\include;..\..\..\Externals\CLRun\include" PreprocessorDefinitions="WIN32;_WINDOWS;_USRDLL;_WIN32;PLUGIN_VIDEOSOFTWARE_EXPORTS;_CRT_SECURE_NO_DEPRECATE;_SECURE_SCL=0" RuntimeLibrary="0" EnableFunctionLevelLinking="true" @@ -329,28 +270,11 @@ Name="VCPreLinkEventTool" /> - @@ -360,9 +284,6 @@ - @@ -603,6 +524,14 @@ RelativePath=".\Src\stdafx.h" > + + + + @@ -647,14 +576,6 @@ RelativePath=".\Src\VertexLoader.h" > - - - - diff --git a/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcxproj b/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcxproj index de442d311366..823fac51d2a2 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcxproj +++ b/Source/Plugins/Plugin_VideoSoftware/Plugin_VideoSoftware.vcxproj @@ -21,26 +21,27 @@ {9E9DA440-E9AD-413C-B648-91030E792211} Plugin_VideoSoftware + VideoSoftware - DynamicLibrary + StaticLibrary true Unicode - DynamicLibrary + StaticLibrary true Unicode - DynamicLibrary + StaticLibrary false true Unicode - DynamicLibrary + StaticLibrary false true Unicode @@ -91,7 +92,7 @@ Level3 Disabled - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\..\Externals\GLew\include;..\..\..\Externals\wxWidgets\Include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\..\Externals\GLew\include;..\..\..\Externals\wxWidgets\Include;%(AdditionalIncludeDirectories) MultiThreadedDebug _SECURE_SCL=0;%(PreprocessorDefinitions) stdafx.h @@ -108,7 +109,7 @@ Level3 Disabled - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\..\Externals\GLew\include;..\..\..\Externals\wxWidgets\Include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\..\Externals\GLew\include;..\..\..\Externals\wxWidgets\Include;%(AdditionalIncludeDirectories) MultiThreadedDebug _SECURE_SCL=0;%(PreprocessorDefinitions) stdafx.h @@ -127,7 +128,7 @@ MaxSpeed true true - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\GLew\include;..\..\..\Externals\wxWidgets\Include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\GLew\include;..\..\..\Externals\wxWidgets\Include;%(AdditionalIncludeDirectories) MultiThreaded _SECURE_SCL=0;%(PreprocessorDefinitions) stdafx.h @@ -148,7 +149,7 @@ MaxSpeed true true - ..\..\Core\Common\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\GLew\include;..\..\..\Externals\wxWidgets\Include;%(AdditionalIncludeDirectories) + ..\..\Core\Common\Src;..\..\Core\Core\Src;..\..\PluginSpecs;..\..\Core\VideoCommon\Src;..\..\Core\VideoUICommon\Src;..\..\..\Externals\GLew\include;..\..\..\Externals\wxWidgets\Include;%(AdditionalIncludeDirectories) MultiThreaded _SECURE_SCL=0;%(PreprocessorDefinitions) stdafx.h @@ -183,17 +184,16 @@ Create - Create Create + Create Create + - - @@ -218,22 +218,19 @@ + - - + - - - {0e231fb1-f3c9-4724-accb-de8bcb3c089e} @@ -248,7 +245,10 @@ {3e5c4e02-1ba9-4776-bdbe-e3f91ffa34cf} + + + - + \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp index 55ce7eed2b4e..3c0b0418e3f3 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/BPMemLoader.cpp @@ -15,7 +15,6 @@ // Official SVN repository and contact information can be found at // http://code.google.com/p/dolphin-emu/ -#include "pluginspecs_video.h" #include "../../../Core/VideoCommon/Src/VideoCommon.h" #include "main.h" @@ -25,9 +24,10 @@ #include "PixelEngine.h" #include "Tev.h" #include "../../../Core/VideoCommon/Src/TextureDecoder.h" +#include "HW/Memmap.h" +#include "Core.h" - -BPMemory bpmem; +extern BPMemory bpmem; void InitBPMemory() { @@ -104,10 +104,10 @@ void BPWritten(int address, int newvalue) u8 *ptr = 0; // TODO - figure out a cleaner way. - if (g_VideoInitialize.bWii) - ptr = g_VideoInitialize.pGetMemoryPointer(bpmem.tlutXferSrc << 5); + if (Core::g_CoreStartupParameter.bWii) + ptr = Memory::GetPointer(bpmem.tlutXferSrc << 5); else - ptr = g_VideoInitialize.pGetMemoryPointer((bpmem.tlutXferSrc & 0xFFFFF) << 5); + ptr = Memory::GetPointer((bpmem.tlutXferSrc & 0xFFFFF) << 5); if (ptr) memcpy_gc(texMem + tlutTMemAddr, ptr, tlutXferCount); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/CPMemLoader.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/CPMemLoader.cpp index 78ae843c37e1..304d7ca5e74f 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/CPMemLoader.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/CPMemLoader.cpp @@ -17,7 +17,7 @@ #include "VideoCommon.h" #include "CPMemLoader.h" - +#include "HW/Memmap.h" // CP state u8 *cached_arraybases[16]; @@ -71,7 +71,7 @@ void LoadCPReg(u32 sub_cmd, u32 value) // Pointers to vertex arrays in GC RAM case 0xA0: arraybases[sub_cmd & 0xF] = value; - cached_arraybases[sub_cmd & 0xF] = Memory_GetPtr(value); + cached_arraybases[sub_cmd & 0xF] = Memory::GetPointer(value); break; case 0xB0: diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/CommandProcessor.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/CommandProcessor.cpp index 1014a35e2388..70254b70bf32 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/CommandProcessor.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/CommandProcessor.cpp @@ -16,9 +16,13 @@ // http://code.google.com/p/dolphin-emu/ #include "Common.h" -#include "pluginspecs_video.h" #include "Thread.h" #include "Atomic.h" +#include "ConfigManager.h" +#include "Core.h" +#include "CoreTiming.h" +#include "HW/Memmap.h" +#include "HW/ProcessorInterface.h" #include "CommandProcessor.h" #include "ChunkFile.h" @@ -109,7 +113,7 @@ void Init() cpreg.token = 0; - et_UpdateInterrupts = g_VideoInitialize.pRegisterEvent("UpdateInterrupts", UpdateInterrupts_Wrapper); + et_UpdateInterrupts = CoreTiming::RegisterEvent("UpdateInterrupts", UpdateInterrupts_Wrapper); // internal buffer position readPos = 0; @@ -128,7 +132,7 @@ void Shutdown() void RunGpu() { - if (!g_VideoInitialize.bOnThread) + if (!SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread) { // We are going to do FP math on the main thread so have to save the current state SaveSSEState(); @@ -309,20 +313,20 @@ void UpdateInterrupts(u64 userdata) { interruptSet = true; INFO_LOG(COMMANDPROCESSOR,"Interrupt set"); - g_VideoInitialize.pSetInterrupt(INT_CAUSE_CP, true); + ProcessorInterface::SetInterrupt(INT_CAUSE_CP, true); } else { interruptSet = false; INFO_LOG(COMMANDPROCESSOR,"Interrupt cleared"); - g_VideoInitialize.pSetInterrupt(INT_CAUSE_CP, false); + ProcessorInterface::SetInterrupt(INT_CAUSE_CP, false); } interruptWaiting = false; } void UpdateInterruptsFromVideoPlugin(u64 userdata) { - g_VideoInitialize.pScheduleEvent_Threadsafe(0, et_UpdateInterrupts, userdata); + CoreTiming::ScheduleEvent_Threadsafe(0, et_UpdateInterrupts, userdata); } void ReadFifo() @@ -333,7 +337,7 @@ void ReadFifo() if (canRead && !atBreakpoint) { // read from fifo - u8 *ptr = g_VideoInitialize.pGetMemoryPointer(cpreg.readptr); + u8 *ptr = Memory::GetPointer(cpreg.readptr); int bytesRead = 0; do @@ -346,7 +350,7 @@ void ReadFifo() if (cpreg.readptr == cpreg.fifoend) { cpreg.readptr = cpreg.fifobase; - ptr = g_VideoInitialize.pGetMemoryPointer(cpreg.readptr); + ptr = Memory::GetPointer(cpreg.readptr); } else { @@ -400,7 +404,7 @@ void SetStatus() if (interrupt != interruptSet && !interruptWaiting) { u64 userdata = interrupt?1:0; - if (g_VideoInitialize.bOnThread) + if (SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread) { interruptWaiting = true; CommandProcessor::UpdateInterruptsFromVideoPlugin(userdata); @@ -470,13 +474,13 @@ bool RunBuffer() // fifo functions #if (SW_PLUGIN) -void Fifo_EnterLoop(const SVideoInitialize &video_initialize) +void Fifo_EnterLoop() { fifoStateRun = true; while (fifoStateRun) { - g_VideoInitialize.pPeekMessages(); + g_video_backend->PeekMessages(); if (!CommandProcessor::RunBuffer()) { Common::YieldCPU(); } diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/CommandProcessor.h b/Source/Plugins/Plugin_VideoSoftware/Src/CommandProcessor.h index 54c2528e6881..ec2d2d085c3b 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/CommandProcessor.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/CommandProcessor.h @@ -19,7 +19,7 @@ #define _COMMANDPROCESSOR_H_ #include "Common.h" -#include "pluginspecs_video.h" + class PointerWrap; extern volatile bool g_bSkipCurrentFrame; @@ -29,7 +29,7 @@ void Fifo_Init(); void Fifo_Shutdown(); void Fifo_DoState(PointerWrap &p); -void Fifo_EnterLoop(const SVideoInitialize &video_initialize); +void Fifo_EnterLoop(); void Fifo_ExitLoop(); void Fifo_SetRendering(bool bEnabled); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/EfbCopy.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/EfbCopy.cpp index cfa5c5e67bdc..4170f3b92a8f 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/EfbCopy.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/EfbCopy.cpp @@ -27,7 +27,8 @@ #include "HwRasterizer.h" #include "CommandProcessor.h" #include "GLUtil.h" - +#include "HW/Memmap.h" +#include "Core.h" namespace EfbCopy { @@ -50,7 +51,7 @@ namespace EfbCopy { if (!g_SWVideoConfig.bHwRasterizer) { - u8 *dest_ptr = g_VideoInitialize.pGetMemoryPointer(bpmem.copyTexDest << 5); + u8 *dest_ptr = Memory::GetPointer(bpmem.copyTexDest << 5); TextureEncoder::Encode(dest_ptr); } @@ -85,7 +86,7 @@ namespace EfbCopy if (bpmem.triggerEFBCopy.copy_to_xfb) { CopyToXfb(); - g_VideoInitialize.pCopiedToXFB(false); + Core::Callback_VideoCopiedToXFB(false); stats.frameCount++; } @@ -107,7 +108,7 @@ namespace EfbCopy if (bpmem.triggerEFBCopy.copy_to_xfb) { // no frame rendered but tell that a frame has finished for frame skip counter - g_VideoInitialize.pCopiedToXFB(false); + Core::Callback_VideoCopiedToXFB(false); } } } diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp index 2fd5905c9d68..ad25418d3d52 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp @@ -19,6 +19,9 @@ #include "SWVideoConfig.h" #include "IniFile.h" #include "Setup.h" +#include "ConfigManager.h" +#include "Core.h" +#include "Host.h" #include "GLUtil.h" @@ -37,6 +40,11 @@ GLWindow GLWin; static int s_backbuffer_width; static int s_backbuffer_height; +static void*& VideoWindowHandle() +{ + return SConfig::GetInstance().m_LocalCoreStartupParameter.hMainWindow; +} + void OpenGL_SwapBuffers() { #if defined(USE_WX) && USE_WX @@ -101,10 +109,10 @@ void UpdateFPSDisplay(const char *text) // Create rendering window. // Call browser: Core.cpp:EmuThread() > main.cpp:Video_Initialize() -bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight) +bool OpenGL_Create(int _twidth, int _theight) { int xPos, yPos; - g_VideoInitialize.pGetWindowSize(xPos, yPos, _twidth, _theight); + Core::Callback_VideoGetWindowSize(xPos, yPos, _twidth, _theight); #if defined(_WIN32) EmuWindow::SetSize(_twidth, _theight); @@ -114,11 +122,8 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight s_backbuffer_width = _twidth; s_backbuffer_height = _theight; - g_VideoInitialize.pPeekMessages = &Callback_PeekMessages; - g_VideoInitialize.pUpdateFPSDisplay = &UpdateFPSDisplay; - #if defined(USE_WX) && USE_WX - GLWin.panel = (wxPanel *)g_VideoInitialize.pWindowHandle; + GLWin.panel = (wxPanel*)VideoWindowHandle(); GLWin.glCanvas = new wxGLCanvas(GLWin.panel, wxID_ANY, NULL, wxPoint(0, 0), wxSize(_twidth, _theight)); GLWin.glCanvas->Show(true); @@ -127,14 +132,14 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight #elif defined(_WIN32) // Create rendering window in Windows - g_VideoInitialize.pWindowHandle = (void*)EmuWindow::Create((HWND)g_VideoInitialize.pWindowHandle, g_hInstance, _T("Please wait...")); + VideoWindowHandle() = (void*)EmuWindow::Create((HWND)VideoWindowHandle(), g_hInstance, _T("Please wait...")); // Show the window EmuWindow::Show(); - if (g_VideoInitialize.pWindowHandle == NULL) + if (VideoWindowHandle() == NULL) { - g_VideoInitialize.pSysMessage("failed to create window"); + Host_SysMessage("failed to create window"); return false; } @@ -301,7 +306,7 @@ bool OpenGL_MakeCurrent() #elif defined(_WIN32) return wglMakeCurrent(hDC,hRC) ? true : false; #elif defined(HAVE_X11) && HAVE_X11 - g_VideoInitialize.pGetWindowSize(GLWin.x, GLWin.y, (int&)GLWin.width, (int&)GLWin.height); + Core::Callback_VideoGetWindowSize(GLWin.x, GLWin.y, (int&)GLWin.width, (int&)GLWin.height); XMoveResizeWindow(GLWin.dpy, GLWin.win, GLWin.x, GLWin.y, GLWin.width, GLWin.height); return glXMakeCurrent(GLWin.dpy, GLWin.win, GLWin.ctx); #endif diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.h b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.h index 33943fe00d95..e28499b4b5a4 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.h @@ -21,7 +21,6 @@ #include #include "SWVideoConfig.h" -#include "pluginspecs_video.h" #ifdef _WIN32 #define GLEW_STATIC @@ -78,7 +77,7 @@ extern GLWindow GLWin; // Public OpenGL util // Initialization / upkeep -bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _width, int _height); +bool OpenGL_Create(int _width, int _height); void OpenGL_Shutdown(); void OpenGL_Update(); bool OpenGL_MakeCurrent(); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp index 05e5467ca65d..54391b278009 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.cpp @@ -29,6 +29,7 @@ #include "DebugUtil.h" #include "CommandProcessor.h" #include "SWVideoConfig.h" +#include "HW/Memmap.h" typedef void (*DecodingFunction)(u32); DecodingFunction currentFunction = NULL; @@ -96,7 +97,7 @@ void ExecuteDisplayList(u32 addr, u32 count) { u8 *videoDataSave = g_pVideoData; - u8 *dlStart = g_VideoInitialize.pGetMemoryPointer(addr); + u8 *dlStart = Memory::GetPointer(addr); g_pVideoData = dlStart; diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.h b/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.h index 66f4d1d3146d..635fcc24ee93 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/OpcodeDecoder.h @@ -19,7 +19,7 @@ #ifndef _OPCODEDECODER_H_ #define _OPCODEDECODER_H_ -#include "pluginspecs_video.h" +#include "CommonTypes.h" namespace OpcodeDecoder { diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/PixelEngine.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/PixelEngine.cpp index 119a3b541733..f59b3f1e19a4 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/PixelEngine.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/PixelEngine.cpp @@ -22,6 +22,9 @@ #include "Common.h" #include "ChunkFile.h" +#include "CoreTiming.h" +#include "ConfigManager.h" +#include "HW/ProcessorInterface.h" #include "PixelEngine.h" #include "CommandProcessor.h" @@ -64,8 +67,8 @@ void Init() et_SetTokenOnMainThread = false; g_bSignalFinishInterrupt = false; - et_SetTokenOnMainThread = g_VideoInitialize.pRegisterEvent("SetToken", SetToken_OnMainThread); - et_SetFinishOnMainThread = g_VideoInitialize.pRegisterEvent("SetFinish", SetFinish_OnMainThread); + et_SetTokenOnMainThread = CoreTiming::RegisterEvent("SetToken", SetToken_OnMainThread); + et_SetFinishOnMainThread = CoreTiming::RegisterEvent("SetFinish", SetFinish_OnMainThread); } void Read16(u16& _uReturnValue, const u32 _iAddress) @@ -114,22 +117,22 @@ void Write16(const u16 _iValue, const u32 _iAddress) bool AllowIdleSkipping() { - return !g_VideoInitialize.bOnThread || (!pereg.ctrl.PETokenEnable && !pereg.ctrl.PEFinishEnable); + return !SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread || (!pereg.ctrl.PETokenEnable && !pereg.ctrl.PEFinishEnable); } void UpdateInterrupts() { // check if there is a token-interrupt if (g_bSignalTokenInterrupt & pereg.ctrl.PETokenEnable) - g_VideoInitialize.pSetInterrupt(INT_CAUSE_PE_TOKEN, true); + ProcessorInterface::SetInterrupt(INT_CAUSE_PE_TOKEN, true); else - g_VideoInitialize.pSetInterrupt(INT_CAUSE_PE_TOKEN, false); + ProcessorInterface::SetInterrupt(INT_CAUSE_PE_TOKEN, false); // check if there is a finish-interrupt if (g_bSignalFinishInterrupt & pereg.ctrl.PEFinishEnable) - g_VideoInitialize.pSetInterrupt(INT_CAUSE_PE_FINISH, true); + ProcessorInterface::SetInterrupt(INT_CAUSE_PE_FINISH, true); else - g_VideoInitialize.pSetInterrupt(INT_CAUSE_PE_FINISH, false); + ProcessorInterface::SetInterrupt(INT_CAUSE_PE_FINISH, false); } @@ -154,8 +157,8 @@ void SetToken(const u16 _token, const int _bSetTokenAcknowledge) pereg.token = _token; if (_bSetTokenAcknowledge) // set token INT { - g_VideoInitialize.pScheduleEvent_Threadsafe( - 0, et_SetTokenOnMainThread, _token | (_bSetTokenAcknowledge << 16)); + CoreTiming::ScheduleEvent_Threadsafe(0, et_SetTokenOnMainThread, + _token | (_bSetTokenAcknowledge << 16)); } } @@ -163,8 +166,7 @@ void SetToken(const u16 _token, const int _bSetTokenAcknowledge) // THIS IS EXECUTED FROM VIDEO THREAD void SetFinish() { - g_VideoInitialize.pScheduleEvent_Threadsafe( - 0, et_SetFinishOnMainThread, 0); + CoreTiming::ScheduleEvent_Threadsafe(0, et_SetFinishOnMainThread, 0); INFO_LOG(PIXELENGINE, "VIDEO Set Finish"); } diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/PixelEngine.h b/Source/Plugins/Plugin_VideoSoftware/Src/PixelEngine.h index 9f7c015c60bd..3147715d38c1 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/PixelEngine.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/PixelEngine.h @@ -18,8 +18,8 @@ #define _PIXELENGINE_H #include "Common.h" -#include "pluginspecs_video.h" #include "VideoCommon.h" + class PointerWrap; namespace PixelEngine diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.cpp index e39638329149..82b51f3b22fa 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.cpp @@ -16,6 +16,7 @@ // http://code.google.com/p/dolphin-emu/ #include "Common.h" +#include "Core.h" #include "GLUtil.h" #include "Renderer.h" @@ -29,17 +30,13 @@ static GLuint s_RenderTarget = 0; RasterFont* s_pfont = NULL; -void Renderer::Init(SVideoInitialize *_pVideoInitialize) +void Renderer::Init() { - if (!OpenGL_Create(g_VideoInitialize, 640, 480)) // 640x480 will be the default if all else fails + if (!OpenGL_Create(640, 480)) // 640x480 will be the default if all else fails { - g_VideoInitialize.pLog("Renderer::Create failed\n", TRUE); + Core::Callback_VideoLog("Renderer::Create failed\n", TRUE); return; } - - _pVideoInitialize->pPeekMessages = g_VideoInitialize.pPeekMessages; - _pVideoInitialize->pUpdateFPSDisplay = g_VideoInitialize.pUpdateFPSDisplay; - _pVideoInitialize->pWindowHandle = g_VideoInitialize.pWindowHandle; } void Renderer::Shutdown() diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.h b/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.h index 06dc9e9d66e5..a23ed4af9960 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Renderer.h @@ -18,11 +18,11 @@ #ifndef _RENDERER_H_ #define _RENDERER_H_ -#include "pluginspecs_video.h" +#include "CommonTypes.h" namespace Renderer { - void Init(SVideoInitialize *_pVideoInitialize); + void Init(); void Prepare(); void Shutdown(); diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/TextureSampler.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/TextureSampler.cpp index 739f1b6d1445..ecb2067a495d 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/TextureSampler.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/TextureSampler.cpp @@ -20,6 +20,7 @@ #include "BPMemLoader.h" #include "../../../Core/VideoCommon/Src/TextureDecoder.h" +#include "HW/Memmap.h" #include @@ -121,7 +122,7 @@ void SampleMip(s32 s, s32 t, s32 mip, bool linear, u8 texmap, u8 *sample) TexTLUT& texTlut = texUnit.texTlut[subTexmap]; u32 imageBase = texUnit.texImage3[subTexmap].image_base << 5; - u8 *imageSrc = g_VideoInitialize.pGetMemoryPointer(imageBase); + u8 *imageSrc = Memory::GetPointer(imageBase); int imageWidth = ti0.width; int imageHeight = ti0.height; diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/VideoBackend.h b/Source/Plugins/Plugin_VideoSoftware/Src/VideoBackend.h new file mode 100644 index 000000000000..379ca13680c9 --- /dev/null +++ b/Source/Plugins/Plugin_VideoSoftware/Src/VideoBackend.h @@ -0,0 +1,46 @@ + +#ifndef SW_VIDEO_BACKEND_H_ +#define SW_VIDEO_BACKEND_H_ + +#include "VideoBackendBase.h" + +namespace SW +{ + +class VideoBackend : public VideoBackendLLE +{ + void Initialize(); + void Shutdown(); + + std::string GetName(); + + void EmuStateChange(PLUGIN_EMUSTATE newState); + + void DoState(PointerWrap &p); + + void ShowConfig(void* parent); + + void Video_Prepare(); + + void Video_EnterLoop(); + void Video_ExitLoop(); + void Video_BeginField(u32, FieldType, u32, u32); + void Video_EndField(); + u32 Video_AccessEFB(EFBAccessType, u32, u32, u32); + + void Video_AddMessage(const char* pstr, unsigned int milliseconds); + bool Video_Screenshot(const char* filename); + + void Video_SetRendering(bool bEnabled); + + void Video_WaitForFrameFinish(); + bool Video_IsFifoBusy(); + void Video_AbortFrame(); + + void UpdateFPSDisplay(const char*); + unsigned int PeekMessages(); +}; + +} + +#endif diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp index 0ff2798a2de6..ced31c3b71f6 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/Win32.cpp @@ -23,54 +23,13 @@ #include #include +#include "ConfigManager.h" #include "SWVideoConfig.h" #include "main.h" #include "Win32.h" #include "StringUtil.h" - -HINSTANCE g_hInstance; - -#if defined(HAVE_WX) && HAVE_WX -class wxDLLApp : public wxApp -{ - bool OnInit() - { - return true; - } -}; -IMPLEMENT_APP_NO_MAIN(wxDLLApp) -WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst); -#endif -// ------------------ - -BOOL APIENTRY DllMain(HINSTANCE hinstDLL, // DLL module handle - DWORD dwReason, // reason called - LPVOID lpvReserved) // reserved -{ - switch (dwReason) - { - case DLL_PROCESS_ATTACH: - { -#if defined(HAVE_WX) && HAVE_WX - wxSetInstance((HINSTANCE)hinstDLL); - wxInitialize(); -#endif - } - break; - - case DLL_PROCESS_DETACH: -#if defined(HAVE_WX) && HAVE_WX - wxUninitialize(); -#endif - break; - } - - g_hInstance = hinstDLL; - return TRUE; -} - // ---------------------- // The rendering window // ---------------------- @@ -80,11 +39,15 @@ namespace EmuWindow HWND m_hWnd = NULL; // The new window that is created here HWND m_hParent = NULL; -HINSTANCE m_hInstance = NULL; WNDCLASSEX wndClass; const TCHAR m_szClassName[] = _T("DolphinEmuWnd"); int g_winstyle; +static void*& VideoWindowHandle() +{ + return SConfig::GetInstance().m_LocalCoreStartupParameter.hMainWindow; +} + // ------------------------------------------ /* Invisible cursor option. In the lack of a predefined IDC_BLANK we make an empty transparent cursor */ @@ -202,7 +165,7 @@ LRESULT CALLBACK WndProc( HWND hWnd, UINT iMsg, WPARAM wParam, LPARAM lParam ) break; case WM_DESTROY: - Shutdown(); + g_video_backend->Shutdown(); break; // Called when a screensaver wants to show up while this window is active @@ -241,10 +204,10 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T wndClass.lpszClassName = m_szClassName; wndClass.hIconSm = LoadIcon( NULL, IDI_APPLICATION ); - m_hInstance = hInstance; + //m_hInstance = hInstance; RegisterClassEx( &wndClass ); - CreateCursors(m_hInstance); + CreateCursors(/*m_hInstance*/GetModuleHandle(0)); // Create child window if (parent) @@ -275,7 +238,7 @@ HWND OpenWindow(HWND parent, HINSTANCE hInstance, int width, int height, const T rc.top = (1024 - h)/2; rc.bottom = rc.top + h; - m_hParent = (HWND)g_VideoInitialize.pWindowHandle; + m_hParent = (HWND)VideoWindowHandle(); m_hWnd = CreateWindow(m_szClassName, title, style, @@ -364,7 +327,7 @@ void Close() { if (!m_hParent) DestroyWindow(m_hWnd); - UnregisterClass(m_szClassName, m_hInstance); + UnregisterClass(m_szClassName, /*m_hInstance*/GetModuleHandle(0)); } // ------------------------------------------ diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/XFMemLoader.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/XFMemLoader.cpp index 371c8937437f..714740e6e934 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/XFMemLoader.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/XFMemLoader.cpp @@ -20,7 +20,7 @@ #include "XFMemLoader.h" #include "CPMemLoader.h" #include "Clipper.h" - +#include "HW/Memmap.h" XFRegisters xfregs; @@ -90,7 +90,7 @@ void LoadIndexedXF(u32 val, int array) int size = ((val >> 12) & 0xF) + 1; //load stuff from array to address in xf mem - u32 *pData = (u32*)g_VideoInitialize.pGetMemoryPointer(arraybases[array] + arraystrides[array]*index); + u32 *pData = (u32*)Memory::GetPointer(arraybases[array] + arraystrides[array]*index); // byteswap data u32 buffer[16]; diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/main.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/main.cpp index 8ece8c950031..13561160e2bf 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/main.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/main.cpp @@ -17,7 +17,6 @@ #include "Common.h" -#include "pluginspecs_video.h" #if defined(HAVE_WX) && HAVE_WX #include "VideoConfigDialog.h" @@ -39,31 +38,14 @@ #include "EfbInterface.h" #include "DebugUtil.h" #include "FileUtil.h" +#include "VideoBackend.h" - -PLUGIN_GLOBALS* globals = NULL; -SVideoInitialize g_VideoInitialize; - - -void GetDllInfo (PLUGIN_INFO* _PluginInfo) +namespace SW { - _PluginInfo->Version = 0x0100; - _PluginInfo->Type = PLUGIN_TYPE_VIDEO; -#ifdef DEBUGFAST - sprintf(_PluginInfo->Name, "Dolphin Software Renderer (DebugFast)"); -#else -#ifndef _DEBUG - sprintf(_PluginInfo->Name, "Dolphin Software Renderer"); -#else - sprintf(_PluginInfo->Name, "Dolphin Software Renderer (Debug)"); -#endif -#endif -} -void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals) +std::string VideoBackend::GetName() { - globals = _pPluginGlobals; - LogManager::SetInstance((LogManager *)globals->logManager); + return "Software Renderer"; } void *DllDebugger(void *_hParent, bool Show) @@ -71,7 +53,7 @@ void *DllDebugger(void *_hParent, bool Show) return NULL; } -void DllConfig(void *_hParent) +void VideoBackend::ShowConfig(void *_hParent) { #if defined(HAVE_WX) && HAVE_WX VideoConfigDialog* const diag = new VideoConfigDialog((wxWindow*)_hParent, "Software", "gfx_software"); @@ -80,11 +62,8 @@ void DllConfig(void *_hParent) #endif } -void Initialize(void *init) +void VideoBackend::Initialize() { - SVideoInitialize *_pVideoInitialize = (SVideoInitialize*)init; - g_VideoInitialize = *_pVideoInitialize; - g_SWVideoConfig.Load((std::string(File::GetUserPath(D_CONFIG_IDX)) + "gfx_software.ini").c_str()); InitBPMemory(); @@ -95,31 +74,33 @@ void Initialize(void *init) Clipper::Init(); Rasterizer::Init(); HwRasterizer::Init(); - Renderer::Init(_pVideoInitialize); + Renderer::Init(); DebugUtil::Init(); } -void DoState(unsigned char **ptr, int mode) +void VideoBackend::DoState(PointerWrap&) { -} -void EmuStateChange(PLUGIN_EMUSTATE newState) -{ } -bool IsD3D() +void VideoBackend::EmuStateChange(PLUGIN_EMUSTATE newState) { - return false; + } -void Shutdown(void) +//bool IsD3D() +//{ +// return false; +//} + +void VideoBackend::Shutdown() { Renderer::Shutdown(); OpenGL_Shutdown(); } // This is called after Video_Initialize() from the Core -void Video_Prepare(void) +void VideoBackend::Video_Prepare() { Renderer::Prepare(); @@ -127,16 +108,16 @@ void Video_Prepare(void) } // Run from the CPU thread (from VideoInterface.cpp) -void Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) +void VideoBackend::Video_BeginField(u32 xfbAddr, FieldType field, u32 fbWidth, u32 fbHeight) { } // Run from the CPU thread (from VideoInterface.cpp) -void Video_EndField() +void VideoBackend::Video_EndField() { } -u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData) +u32 VideoBackend::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData) { u32 value = 0; @@ -166,71 +147,46 @@ u32 Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData) return value; } -void Video_Screenshot(const char *_szFilename) +bool VideoBackend::Video_Screenshot(const char *_szFilename) { + return false; } // ------------------------------- // Enter and exit the video loop // ------------------------------- -void Video_EnterLoop() +void VideoBackend::Video_EnterLoop() { - Fifo_EnterLoop(g_VideoInitialize); + Fifo_EnterLoop(); } -void Video_ExitLoop() +void VideoBackend::Video_ExitLoop() { Fifo_ExitLoop(); } -void Video_AddMessage(const char* pstr, u32 milliseconds) +void VideoBackend::Video_AddMessage(const char* pstr, u32 milliseconds) { } -void Video_SetRendering(bool bEnabled) +void VideoBackend::Video_SetRendering(bool bEnabled) { Fifo_SetRendering(bEnabled); } -void Video_CommandProcessorRead16(u16& _rReturnValue, const u32 _Address) -{ - CommandProcessor::Read16(_rReturnValue, _Address); -} - -void Video_CommandProcessorWrite16(const u16 _Data, const u32 _Address) -{ - CommandProcessor::Write16(_Data, _Address); -} - -void Video_PixelEngineRead16(u16& _rReturnValue, const u32 _Address) +void VideoBackend::Video_WaitForFrameFinish(void) { - PixelEngine::Read16(_rReturnValue, _Address); -} -void Video_PixelEngineWrite16(const u16 _Data, const u32 _Address) -{ - PixelEngine::Write16(_Data, _Address); } -void Video_PixelEngineWrite32(const u32 _Data, const u32 _Address) +bool VideoBackend::Video_IsFifoBusy(void) { - PixelEngine::Write32(_Data, _Address); -} - -void Video_GatherPipeBursted(void) -{ - CommandProcessor::GatherPipeBursted(); + return false; } -void Video_WaitForFrameFinish(void) +void VideoBackend::Video_AbortFrame(void) { -} -bool Video_IsFifoBusy(void) -{ - return false; } -void Video_AbortFrame(void) -{ -} +} \ No newline at end of file diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/main.h b/Source/Plugins/Plugin_VideoSoftware/Src/main.h index f025610cae89..673998f5921f 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/main.h +++ b/Source/Plugins/Plugin_VideoSoftware/Src/main.h @@ -18,8 +18,6 @@ #ifndef MAIN_H #define MAIN_H -#include "pluginspecs_video.h" - -extern SVideoInitialize g_VideoInitialize; +#include "VideoBackend.h" #endif