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:
Jordan Woyak
2011-01-31 01:28:32 +00:00
parent ae7c64ec13
commit fbaf965995
136 changed files with 1537 additions and 3412 deletions

View File

@ -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_

View File

@ -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 @@ public:
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

View File

@ -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

View File

@ -24,7 +24,8 @@
class PIXELSHADERUID;
enum DSTALPHA_MODE;
namespace DX11 {
namespace DX11
{
class PixelShaderCache
{
@ -61,4 +62,4 @@ private:
static const PSCacheEntry* last_entry;
};
} // namespace DX11
} // namespace DX11

View File

@ -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;
}

View File

@ -49,6 +49,15 @@ public:
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);
};
}

View File

@ -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;
}
}
} // namespace DX11

View File

@ -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

View File

@ -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;
void*& VideoWindowHandle()
{
return SConfig::GetInstance().m_LocalCoreStartupParameter.hMainWindow;
}
// This is used for the functions right below here which use wxwidgets
WXDLLIMPEXP_BASE void wxSetInstance(HINSTANCE hInst);
void *DllDebugger(void *_hParent, bool Show)
{
return new GFXDebuggerPanel((wxWindow*)_hParent);
}
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)
{
_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 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
//}
void SetDllGlobals(PLUGIN_GLOBALS* _pPluginGlobals)
std::string VideoBackend::GetName()
{
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;
}
}

View File

@ -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