mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 22:29:39 -06:00
Eliminated the plugin interface. Merged DX9/DX11/OGL video plugins into Dolphin. It could still use a lot of cleanup. Lots of things are still named "plugin". Software renderer is temporarily disabled until it gets some namespaces. I only updated vs08/10, Linux/OSX builds are broken.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6996 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
@ -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 <string.h> // System
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
#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;
|
||||
}
|
@ -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 <windows.h>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
|
||||
/* 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_
|
@ -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<TGetDllInfo>
|
||||
(m_hInstLib.Get("GetDllInfo"));
|
||||
m_DllConfig = reinterpret_cast<TDllConfig>
|
||||
(m_hInstLib.Get("DllConfig"));
|
||||
m_DllDebugger = reinterpret_cast<TDllDebugger>
|
||||
(m_hInstLib.Get("DllDebugger"));
|
||||
m_SetDllGlobals = reinterpret_cast<TSetDllGlobals>
|
||||
(m_hInstLib.Get("SetDllGlobals"));
|
||||
m_Initialize = reinterpret_cast<TInitialize>
|
||||
(m_hInstLib.Get("Initialize"));
|
||||
m_Shutdown = reinterpret_cast<TShutdown>
|
||||
(m_hInstLib.Get("Shutdown"));
|
||||
m_DoState = reinterpret_cast<TDoState>
|
||||
(m_hInstLib.Get("DoState"));
|
||||
m_EmuStateChange = reinterpret_cast<TEmuStateChange>
|
||||
(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
|
@ -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_
|
@ -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<TVideo_Prepare>
|
||||
(LoadSymbol("Video_Prepare"));
|
||||
Video_BeginField = reinterpret_cast<TVideo_BeginField>
|
||||
(LoadSymbol("Video_BeginField"));
|
||||
Video_EndField = reinterpret_cast<TVideo_EndField>
|
||||
(LoadSymbol("Video_EndField"));
|
||||
Video_Screenshot = reinterpret_cast<TVideo_Screenshot>
|
||||
(LoadSymbol("Video_Screenshot"));
|
||||
Video_EnterLoop = reinterpret_cast<TVideo_EnterLoop>
|
||||
(LoadSymbol("Video_EnterLoop"));
|
||||
Video_ExitLoop = reinterpret_cast<TVideo_ExitLoop>
|
||||
(LoadSymbol("Video_ExitLoop"));
|
||||
Video_AddMessage = reinterpret_cast<TVideo_AddMessage>
|
||||
(LoadSymbol("Video_AddMessage"));
|
||||
Video_AccessEFB = reinterpret_cast<TVideo_AccessEFB>
|
||||
(LoadSymbol("Video_AccessEFB"));
|
||||
Video_SetRendering = reinterpret_cast<TVideo_SetRendering>
|
||||
(LoadSymbol("Video_SetRendering"));
|
||||
Video_CommandProcessorRead16 = reinterpret_cast<TVideo_Read16>
|
||||
(LoadSymbol("Video_CommandProcessorRead16"));
|
||||
Video_CommandProcessorWrite16 = reinterpret_cast<TVideo_Write16>
|
||||
(LoadSymbol("Video_CommandProcessorWrite16"));
|
||||
Video_PixelEngineRead16 = reinterpret_cast<TVideo_Read16>
|
||||
(LoadSymbol("Video_PixelEngineRead16"));
|
||||
Video_PixelEngineWrite16 = reinterpret_cast<TVideo_Write16>
|
||||
(LoadSymbol("Video_PixelEngineWrite16"));
|
||||
Video_PixelEngineWrite32 = reinterpret_cast<TVideo_Write32>
|
||||
(LoadSymbol("Video_PixelEngineWrite32"));
|
||||
Video_GatherPipeBursted = reinterpret_cast<TVideo_GatherPipeBursted>
|
||||
(LoadSymbol("Video_GatherPipeBursted"));
|
||||
Video_WaitForFrameFinish = reinterpret_cast<TVideo_WaitForFrameFinish>
|
||||
(LoadSymbol("Video_WaitForFrameFinish"));
|
||||
Video_IsFifoBusy = reinterpret_cast<TVideo_IsFifoBusy>
|
||||
(LoadSymbol("Video_IsFifoBusy"));
|
||||
Video_AbortFrame = reinterpret_cast<TVideo_AbortFrame>
|
||||
(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
|
@ -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_
|
58
Source/Core/Common/Src/VideoBackendBase.cpp
Normal file
58
Source/Core/Common/Src/VideoBackendBase.cpp
Normal file
@ -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<VideoBackend*> 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<VideoBackend*>::const_iterator it = g_available_video_backends.begin(); it != g_available_video_backends.end(); ++it)
|
||||
if (name == (*it)->GetName())
|
||||
g_video_backend = *it;
|
||||
}
|
156
Source/Core/Common/Src/VideoBackendBase.h
Normal file
156
Source/Core/Common/Src/VideoBackendBase.h
Normal file
@ -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 <string>
|
||||
#include <vector>
|
||||
|
||||
#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<VideoBackend*> 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
|
Reference in New Issue
Block a user