Merge pull request #3510 from degasus/master

VideoBackends: Merge backend initialization and shutdown.
This commit is contained in:
Markus Wick 2016-06-26 12:48:59 +02:00 committed by GitHub
commit 3887328bba
37 changed files with 154 additions and 346 deletions

View File

@ -143,7 +143,7 @@ void Host_SetWiiMoteConnectionState(int _State)
{ {
} }
void Host_ShowVideoConfig(void*, const std::string&, const std::string&) void Host_ShowVideoConfig(void*, const std::string&)
{ {
} }

View File

@ -37,8 +37,7 @@ void Host_SetWiiMoteConnectionState(int _State);
void Host_UpdateDisasmDialog(); void Host_UpdateDisasmDialog();
void Host_UpdateMainFrame(); void Host_UpdateMainFrame();
void Host_UpdateTitle(const std::string& title); void Host_UpdateTitle(const std::string& title);
void Host_ShowVideoConfig(void* parent, const std::string& backend_name, void Host_ShowVideoConfig(void* parent, const std::string& backend_name);
const std::string& config_name);
// TODO (neobrain): Remove this from host! // TODO (neobrain): Remove this from host!
void* Host_GetRenderHandle(); void* Host_GetRenderHandle();

View File

@ -121,8 +121,7 @@ void Host_SetWiiMoteConnectionState(int state)
void Host_ConnectWiimote(int wm_idx, bool connect) void Host_ConnectWiimote(int wm_idx, bool connect)
{ {
} }
void Host_ShowVideoConfig(void* parent, const std::string& backend_name, void Host_ShowVideoConfig(void* parent, const std::string& backend_name)
const std::string& config_name)
{ {
} }
void Host_RefreshDSPDebuggerWindow() void Host_RefreshDSPDebuggerWindow()

View File

@ -555,17 +555,16 @@ void Host_ConnectWiimote(int wm_idx, bool connect)
} }
} }
void Host_ShowVideoConfig(void* parent, const std::string& backend_name, void Host_ShowVideoConfig(void* parent, const std::string& backend_name)
const std::string& config_name)
{ {
if (backend_name == "Software Renderer") if (backend_name == "Software Renderer")
{ {
SoftwareVideoConfigDialog diag((wxWindow*)parent, backend_name, config_name); SoftwareVideoConfigDialog diag((wxWindow*)parent, backend_name);
diag.ShowModal(); diag.ShowModal();
} }
else else
{ {
VideoConfigDiag diag((wxWindow*)parent, backend_name, config_name); VideoConfigDiag diag((wxWindow*)parent, backend_name);
diag.ShowModal(); diag.ShowModal();
} }
} }

View File

@ -136,7 +136,7 @@ void Host_SetWiiMoteConnectionState(int _State)
{ {
} }
void Host_ShowVideoConfig(void*, const std::string&, const std::string&) void Host_ShowVideoConfig(void*, const std::string&)
{ {
} }

View File

@ -31,17 +31,13 @@ IntegerSetting<T>::IntegerSetting(wxWindow* parent, const wxString& label, T& se
Bind(wxEVT_SPINCTRL, &IntegerSetting::UpdateValue, this); Bind(wxEVT_SPINCTRL, &IntegerSetting::UpdateValue, this);
} }
SoftwareVideoConfigDialog::SoftwareVideoConfigDialog(wxWindow* parent, const std::string& title, SoftwareVideoConfigDialog::SoftwareVideoConfigDialog(wxWindow* parent, const std::string& title)
const std::string& ininame)
: wxDialog(parent, wxID_ANY, : wxDialog(parent, wxID_ANY,
wxString(wxString::Format(_("Dolphin %s Graphics Configuration"), title))) wxString(wxString::Format(_("Dolphin %s Graphics Configuration"), title)))
{ {
VideoConfig& vconfig = g_Config; VideoConfig& vconfig = g_Config;
if (File::Exists(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini")) vconfig.Load(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini");
vconfig.Load(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini");
else
vconfig.Load(File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini");
wxNotebook* const notebook = new wxNotebook(this, wxID_ANY); wxNotebook* const notebook = new wxNotebook(this, wxID_ANY);

View File

@ -19,7 +19,7 @@
class SoftwareVideoConfigDialog : public wxDialog class SoftwareVideoConfigDialog : public wxDialog
{ {
public: public:
SoftwareVideoConfigDialog(wxWindow* parent, const std::string& title, const std::string& ininame); SoftwareVideoConfigDialog(wxWindow* parent, const std::string& title);
~SoftwareVideoConfigDialog(); ~SoftwareVideoConfigDialog();
void Event_Backend(wxCommandEvent& ev) void Event_Backend(wxCommandEvent& ev)

View File

@ -329,16 +329,12 @@ static wxArrayString GetListOfResolutions()
} }
#endif #endif
VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title, VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title)
const std::string& ininame)
: wxDialog(parent, wxID_ANY, wxString::Format(_("Dolphin %s Graphics Configuration"), : wxDialog(parent, wxID_ANY, wxString::Format(_("Dolphin %s Graphics Configuration"),
wxGetTranslation(StrToWxStr(title)))), wxGetTranslation(StrToWxStr(title)))),
vconfig(g_Config) vconfig(g_Config)
{ {
if (File::Exists(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini")) vconfig.Load(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini");
vconfig.Load(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini");
else
vconfig.Load(File::GetUserPath(D_CONFIG_IDX) + ininame + ".ini");
Bind(wxEVT_UPDATE_UI, &VideoConfigDiag::OnUpdateUI, this); Bind(wxEVT_UPDATE_UI, &VideoConfigDiag::OnUpdateUI, this);

View File

@ -83,7 +83,7 @@ private:
class VideoConfigDiag : public wxDialog class VideoConfigDiag : public wxDialog
{ {
public: public:
VideoConfigDiag(wxWindow* parent, const std::string& title, const std::string& ininame); VideoConfigDiag(wxWindow* parent, const std::string& title);
protected: protected:
void Event_Backend(wxCommandEvent& ev) void Event_Backend(wxCommandEvent& ev)

View File

@ -20,7 +20,7 @@ class VideoBackend : public VideoBackendBase
void Video_Prepare() override; void Video_Prepare() override;
void Video_Cleanup() override; void Video_Cleanup() override;
void ShowConfig(void* parent) override; void InitBackendInfo() override;
unsigned int PeekMessages() override; unsigned int PeekMessages() override;

View File

@ -61,7 +61,7 @@ std::string VideoBackend::GetDisplayName() const
return "Direct3D 11"; return "Direct3D 11";
} }
void InitBackendInfo() void VideoBackend::InitBackendInfo()
{ {
HRESULT hr = DX11::D3D::LoadDXGI(); HRESULT hr = DX11::D3D::LoadDXGI();
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
@ -138,34 +138,15 @@ void InitBackendInfo()
DX11::D3D::UnloadD3D(); DX11::D3D::UnloadD3D();
} }
void VideoBackend::ShowConfig(void* hParent)
{
InitBackendInfo();
Host_ShowVideoConfig(hParent, GetDisplayName(), "gfx_dx11");
}
bool VideoBackend::Initialize(void* window_handle) bool VideoBackend::Initialize(void* window_handle)
{ {
if (window_handle == nullptr) if (window_handle == nullptr)
return false; return false;
InitializeShared();
InitBackendInfo(); InitBackendInfo();
InitializeShared();
frameCount = 0;
if (File::Exists(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini"))
g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini");
else
g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + "gfx_dx11.ini");
g_Config.GameIniLoad();
g_Config.UpdateProjectionHack();
g_Config.VerifyValidity();
UpdateActiveConfig();
m_window_handle = window_handle; m_window_handle = window_handle;
m_initialized = true;
return true; return true;
} }
@ -181,55 +162,27 @@ void VideoBackend::Video_Prepare()
PixelShaderCache::Init(); PixelShaderCache::Init();
GeometryShaderCache::Init(); GeometryShaderCache::Init();
D3D::InitUtils(); D3D::InitUtils();
// VideoCommon
BPInit();
Fifo::Init();
IndexGenerator::Init();
VertexLoaderManager::Init();
OpcodeDecoder::Init();
VertexShaderManager::Init();
PixelShaderManager::Init();
GeometryShaderManager::Init();
CommandProcessor::Init();
PixelEngine::Init();
BBox::Init();
// Tell the host that the window is ready
Host_Message(WM_USER_CREATE);
} }
void VideoBackend::Shutdown() void VideoBackend::Shutdown()
{ {
m_initialized = false;
// TODO: should be in Video_Cleanup // TODO: should be in Video_Cleanup
if (g_renderer) D3D::ShutdownUtils();
{ PixelShaderCache::Shutdown();
// VideoCommon VertexShaderCache::Shutdown();
Fifo::Shutdown(); GeometryShaderCache::Shutdown();
CommandProcessor::Shutdown(); BBox::Shutdown();
GeometryShaderManager::Shutdown();
PixelShaderManager::Shutdown();
VertexShaderManager::Shutdown();
OpcodeDecoder::Shutdown();
VertexLoaderManager::Shutdown();
// internal interfaces g_perf_query.reset();
D3D::ShutdownUtils(); g_vertex_manager.reset();
PixelShaderCache::Shutdown(); g_texture_cache.reset();
VertexShaderCache::Shutdown(); g_renderer.reset();
GeometryShaderCache::Shutdown();
BBox::Shutdown();
g_perf_query.reset(); ShutdownShared();
g_vertex_manager.reset();
g_texture_cache.reset();
g_renderer.reset();
}
} }
void VideoBackend::Video_Cleanup() void VideoBackend::Video_Cleanup()
{ {
CleanupShared();
} }
} }

View File

@ -20,7 +20,7 @@ class VideoBackend : public VideoBackendBase
void Video_Prepare() override; void Video_Prepare() override;
void Video_Cleanup() override; void Video_Cleanup() override;
void ShowConfig(void* parent) override; void InitBackendInfo() override;
unsigned int PeekMessages() override; unsigned int PeekMessages() override;

View File

@ -62,7 +62,7 @@ std::string VideoBackend::GetDisplayName() const
return "Direct3D 12 (experimental)"; return "Direct3D 12 (experimental)";
} }
void InitBackendInfo() void VideoBackend::InitBackendInfo()
{ {
HRESULT hr = D3D::LoadDXGI(); HRESULT hr = D3D::LoadDXGI();
if (FAILED(hr)) if (FAILED(hr))
@ -152,37 +152,18 @@ void InitBackendInfo()
D3D::UnloadDXGI(); D3D::UnloadDXGI();
} }
void VideoBackend::ShowConfig(void* hParent)
{
InitBackendInfo();
Host_ShowVideoConfig(hParent, GetDisplayName(), "gfx_dx12");
}
bool VideoBackend::Initialize(void* window_handle) bool VideoBackend::Initialize(void* window_handle)
{ {
if (window_handle == nullptr) if (window_handle == nullptr)
return false; return false;
InitializeShared();
InitBackendInfo(); InitBackendInfo();
InitializeShared();
frameCount = 0;
if (File::Exists(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini"))
g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini");
else
g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + "gfx_dx12.ini");
g_Config.GameIniLoad();
g_Config.UpdateProjectionHack();
g_Config.VerifyValidity();
UpdateActiveConfig();
if (FAILED(D3D::Create((HWND)window_handle))) if (FAILED(D3D::Create((HWND)window_handle)))
return false; return false;
m_window_handle = window_handle; m_window_handle = window_handle;
m_initialized = true;
return true; return true;
} }
@ -200,62 +181,36 @@ void VideoBackend::Video_Prepare()
StaticShaderCache::Init(); StaticShaderCache::Init();
StateCache::Init(); // PSO cache is populated here, after constituent shaders are loaded. StateCache::Init(); // PSO cache is populated here, after constituent shaders are loaded.
D3D::InitUtils(); D3D::InitUtils();
// VideoCommon
BPInit();
Fifo::Init();
IndexGenerator::Init();
VertexLoaderManager::Init();
OpcodeDecoder::Init();
VertexShaderManager::Init();
PixelShaderManager::Init();
GeometryShaderManager::Init();
CommandProcessor::Init();
PixelEngine::Init();
BBox::Init();
// Tell the host that the window is ready
Host_Message(WM_USER_CREATE);
} }
void VideoBackend::Shutdown() void VideoBackend::Shutdown()
{ {
m_initialized = true;
// TODO: should be in Video_Cleanup // TODO: should be in Video_Cleanup
if (g_renderer)
{
// Immediately stop app from submitting work to GPU, and wait for all submitted work to
// complete. D3D12TODO: Check this.
D3D::command_list_mgr->ExecuteQueuedWork(true);
// VideoCommon // Immediately stop app from submitting work to GPU, and wait for all submitted work to complete.
Fifo::Shutdown(); // D3D12TODO: Check this.
CommandProcessor::Shutdown(); D3D::command_list_mgr->ExecuteQueuedWork(true);
GeometryShaderManager::Shutdown();
PixelShaderManager::Shutdown();
VertexShaderManager::Shutdown();
OpcodeDecoder::Shutdown();
VertexLoaderManager::Shutdown();
// internal interfaces // internal interfaces
D3D::ShutdownUtils(); D3D::ShutdownUtils();
ShaderCache::Shutdown(); ShaderCache::Shutdown();
ShaderConstantsManager::Shutdown(); ShaderConstantsManager::Shutdown();
StaticShaderCache::Shutdown(); StaticShaderCache::Shutdown();
BBox::Shutdown(); BBox::Shutdown();
g_xfb_encoder.reset(); g_xfb_encoder.reset();
g_perf_query.reset(); g_perf_query.reset();
g_vertex_manager.reset(); g_vertex_manager.reset();
g_texture_cache.reset(); g_texture_cache.reset();
g_renderer.reset(); g_renderer.reset();
D3D::Close(); D3D::Close();
}
ShutdownShared();
} }
void VideoBackend::Video_Cleanup() void VideoBackend::Video_Cleanup()
{ {
CleanupShared();
} }
} }

View File

@ -32,7 +32,7 @@
namespace Null namespace Null
{ {
static void InitBackendInfo() void VideoBackend::InitBackendInfo()
{ {
g_Config.backend_info.APIType = API_NONE; g_Config.backend_info.APIType = API_NONE;
g_Config.backend_info.bSupportsExclusiveFullscreen = true; g_Config.backend_info.bSupportsExclusiveFullscreen = true;
@ -50,39 +50,11 @@ static void InitBackendInfo()
g_Config.backend_info.AAModes = {1}; g_Config.backend_info.AAModes = {1};
} }
void VideoBackend::ShowConfig(void* parent)
{
InitBackendInfo();
Host_ShowVideoConfig(parent, GetDisplayName(), "gfx_null");
}
bool VideoBackend::Initialize(void* window_handle) bool VideoBackend::Initialize(void* window_handle)
{ {
InitializeShared(); InitializeShared();
InitBackendInfo(); InitBackendInfo();
// Load Configs
g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini");
g_Config.GameIniLoad();
g_Config.UpdateProjectionHack();
g_Config.VerifyValidity();
UpdateActiveConfig();
// Do our OSD callbacks
OSD::DoCallbacks(OSD::CallbackType::Initialization);
// Initialize VideoCommon
CommandProcessor::Init();
PixelEngine::Init();
BPInit();
Fifo::Init();
OpcodeDecoder::Init();
IndexGenerator::Init();
VertexShaderManager::Init();
PixelShaderManager::Init();
VertexLoaderManager::Init();
Host_Message(WM_USER_CREATE);
return true; return true;
} }
@ -102,19 +74,12 @@ void VideoBackend::Video_Prepare()
void VideoBackend::Shutdown() void VideoBackend::Shutdown()
{ {
// Shutdown VideoCommon ShutdownShared();
Fifo::Shutdown();
VertexLoaderManager::Shutdown();
VertexShaderManager::Shutdown();
PixelShaderManager::Shutdown();
OpcodeDecoder::Shutdown();
// Do our OSD callbacks
OSD::DoCallbacks(OSD::CallbackType::Shutdown);
} }
void VideoBackend::Video_Cleanup() void VideoBackend::Video_Cleanup()
{ {
CleanupShared();
PixelShaderCache::s_instance.reset(); PixelShaderCache::s_instance.reset();
VertexShaderCache::s_instance.reset(); VertexShaderCache::s_instance.reset();
GeometryShaderCache::s_instance.reset(); GeometryShaderCache::s_instance.reset();

View File

@ -18,7 +18,7 @@ class VideoBackend : public VideoBackendBase
void Video_Prepare() override; void Video_Prepare() override;
void Video_Cleanup() override; void Video_Cleanup() override;
void ShowConfig(void* parent) override; void InitBackendInfo() override;
unsigned int PeekMessages() override { return 0; } unsigned int PeekMessages() override { return 0; }
}; };

View File

@ -39,6 +39,7 @@
#include "VideoCommon/DriverDetails.h" #include "VideoCommon/DriverDetails.h"
#include "VideoCommon/Fifo.h" #include "VideoCommon/Fifo.h"
#include "VideoCommon/ImageWrite.h" #include "VideoCommon/ImageWrite.h"
#include "VideoCommon/IndexGenerator.h"
#include "VideoCommon/OnScreenDisplay.h" #include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/PixelEngine.h" #include "VideoCommon/PixelEngine.h"
#include "VideoCommon/PixelShaderManager.h" #include "VideoCommon/PixelShaderManager.h"
@ -753,6 +754,8 @@ Renderer::Renderer()
} }
} }
} }
IndexGenerator::Init();
UpdateActiveConfig(); UpdateActiveConfig();
ClearEFBCache(); ClearEFBCache();
} }

View File

@ -20,7 +20,7 @@ class VideoBackend : public VideoBackendBase
void Video_Prepare() override; void Video_Prepare() override;
void Video_Cleanup() override; void Video_Cleanup() override;
void ShowConfig(void* parent) override; void InitBackendInfo() override;
unsigned int PeekMessages() override; unsigned int PeekMessages() override;
}; };

View File

@ -106,7 +106,7 @@ static std::vector<std::string> GetShaders(const std::string& sub_dir = "")
return result; return result;
} }
static void InitBackendInfo() void VideoBackend::InitBackendInfo()
{ {
g_Config.backend_info.APIType = API_OPENGL; g_Config.backend_info.APIType = API_OPENGL;
g_Config.backend_info.bSupportsExclusiveFullscreen = false; g_Config.backend_info.bSupportsExclusiveFullscreen = false;
@ -116,6 +116,12 @@ static void InitBackendInfo()
g_Config.backend_info.bSupportsPostProcessing = true; g_Config.backend_info.bSupportsPostProcessing = true;
g_Config.backend_info.bSupportsSSAA = true; g_Config.backend_info.bSupportsSSAA = true;
// Overwritten in Render.cpp later
g_Config.backend_info.bSupportsDualSourceBlend = true;
g_Config.backend_info.bSupportsPrimitiveRestart = true;
g_Config.backend_info.bSupportsPaletteConversion = true;
g_Config.backend_info.bSupportsClipControl = true;
g_Config.backend_info.Adapters.clear(); g_Config.backend_info.Adapters.clear();
// aamodes - 1 is to stay consistent with D3D (means no AA) // aamodes - 1 is to stay consistent with D3D (means no AA)
@ -126,40 +132,16 @@ static void InitBackendInfo()
g_Config.backend_info.AnaglyphShaders = GetShaders(ANAGLYPH_DIR DIR_SEP); g_Config.backend_info.AnaglyphShaders = GetShaders(ANAGLYPH_DIR DIR_SEP);
} }
void VideoBackend::ShowConfig(void* parent_handle)
{
if (!m_initialized)
InitBackendInfo();
Host_ShowVideoConfig(parent_handle, GetDisplayName(), "gfx_opengl");
}
bool VideoBackend::Initialize(void* window_handle) bool VideoBackend::Initialize(void* window_handle)
{ {
InitializeShared();
InitBackendInfo(); InitBackendInfo();
InitializeShared();
frameCount = 0;
if (File::Exists(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini"))
g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini");
else
g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + "gfx_opengl.ini");
g_Config.GameIniLoad();
g_Config.UpdateProjectionHack();
g_Config.VerifyValidity();
UpdateActiveConfig();
InitInterface(); InitInterface();
GLInterface->SetMode(GLInterfaceMode::MODE_DETECT); GLInterface->SetMode(GLInterfaceMode::MODE_DETECT);
if (!GLInterface->Create(window_handle)) if (!GLInterface->Create(window_handle))
return false; return false;
// Do our OSD callbacks
OSD::DoCallbacks(OSD::CallbackType::Initialization);
m_initialized = true;
return true; return true;
} }
@ -171,65 +153,36 @@ void VideoBackend::Video_Prepare()
g_renderer = std::make_unique<Renderer>(); g_renderer = std::make_unique<Renderer>();
CommandProcessor::Init();
PixelEngine::Init();
BPInit();
g_vertex_manager = std::make_unique<VertexManager>(); g_vertex_manager = std::make_unique<VertexManager>();
g_perf_query = GetPerfQuery(); g_perf_query = GetPerfQuery();
Fifo::Init(); // must be done before OpcodeDecoder::Init()
OpcodeDecoder::Init();
IndexGenerator::Init();
VertexShaderManager::Init();
PixelShaderManager::Init();
GeometryShaderManager::Init();
ProgramShaderCache::Init(); ProgramShaderCache::Init();
g_texture_cache = std::make_unique<TextureCache>(); g_texture_cache = std::make_unique<TextureCache>();
g_sampler_cache = std::make_unique<SamplerCache>(); g_sampler_cache = std::make_unique<SamplerCache>();
Renderer::Init(); Renderer::Init();
VertexLoaderManager::Init();
TextureConverter::Init(); TextureConverter::Init();
BoundingBox::Init(); BoundingBox::Init();
// Notify the core that the video backend is ready
Host_Message(WM_USER_CREATE);
} }
void VideoBackend::Shutdown() void VideoBackend::Shutdown()
{ {
m_initialized = false;
// Do our OSD callbacks
OSD::DoCallbacks(OSD::CallbackType::Shutdown);
GLInterface->Shutdown(); GLInterface->Shutdown();
GLInterface.reset(); GLInterface.reset();
ShutdownShared();
} }
void VideoBackend::Video_Cleanup() void VideoBackend::Video_Cleanup()
{ {
if (!g_renderer)
return;
Fifo::Shutdown();
// The following calls are NOT Thread Safe // The following calls are NOT Thread Safe
// And need to be called from the video thread // And need to be called from the video thread
CleanupShared();
Renderer::Shutdown(); Renderer::Shutdown();
BoundingBox::Shutdown(); BoundingBox::Shutdown();
TextureConverter::Shutdown(); TextureConverter::Shutdown();
VertexLoaderManager::Shutdown();
g_sampler_cache.reset(); g_sampler_cache.reset();
g_texture_cache.reset(); g_texture_cache.reset();
ProgramShaderCache::Shutdown(); ProgramShaderCache::Shutdown();
VertexShaderManager::Shutdown();
PixelShaderManager::Shutdown();
GeometryShaderManager::Shutdown();
g_perf_query.reset(); g_perf_query.reset();
g_vertex_manager.reset(); g_vertex_manager.reset();
OpcodeDecoder::Shutdown();
g_renderer.reset(); g_renderer.reset();
GLInterface->ClearCurrent(); GLInterface->ClearCurrent();
} }

View File

@ -134,7 +134,7 @@ std::string VideoSoftware::GetDisplayName() const
return "Software Renderer"; return "Software Renderer";
} }
static void InitBackendInfo() void VideoSoftware::InitBackendInfo()
{ {
g_Config.backend_info.APIType = API_NONE; g_Config.backend_info.APIType = API_NONE;
g_Config.backend_info.bSupports3DVision = false; g_Config.backend_info.bSupports3DVision = false;
@ -147,23 +147,10 @@ static void InitBackendInfo()
g_Config.backend_info.AAModes = {1}; g_Config.backend_info.AAModes = {1};
} }
void VideoSoftware::ShowConfig(void* hParent)
{
if (!m_initialized)
InitBackendInfo();
Host_ShowVideoConfig(hParent, GetDisplayName(), "gfx_software");
}
bool VideoSoftware::Initialize(void* window_handle) bool VideoSoftware::Initialize(void* window_handle)
{ {
InitializeShared();
InitBackendInfo(); InitBackendInfo();
InitializeShared();
g_Config.Load((File::GetUserPath(D_CONFIG_IDX) + "gfx_software.ini").c_str());
g_Config.GameIniLoad();
g_Config.UpdateProjectionHack();
g_Config.VerifyValidity();
UpdateActiveConfig();
SWOGLWindow::Init(window_handle); SWOGLWindow::Init(window_handle);
@ -173,71 +160,41 @@ bool VideoSoftware::Initialize(void* window_handle)
SWRenderer::Init(); SWRenderer::Init();
DebugUtil::Init(); DebugUtil::Init();
// Do our OSD callbacks
OSD::DoCallbacks(OSD::CallbackType::Initialization);
m_initialized = true;
return true; return true;
} }
void VideoSoftware::Shutdown() void VideoSoftware::Shutdown()
{ {
m_initialized = false;
// Do our OSD callbacks
OSD::DoCallbacks(OSD::CallbackType::Shutdown);
SWOGLWindow::Shutdown(); SWOGLWindow::Shutdown();
ShutdownShared();
} }
void VideoSoftware::Video_Cleanup() void VideoSoftware::Video_Cleanup()
{ {
if (g_renderer) CleanupShared();
{
Fifo::Shutdown(); SWRenderer::Shutdown();
SWRenderer::Shutdown(); DebugUtil::Shutdown();
DebugUtil::Shutdown(); // The following calls are NOT Thread Safe
// The following calls are NOT Thread Safe // And need to be called from the video thread
// And need to be called from the video thread SWRenderer::Shutdown();
SWRenderer::Shutdown(); g_framebuffer_manager.reset();
VertexLoaderManager::Shutdown(); g_texture_cache.reset();
g_framebuffer_manager.reset(); g_perf_query.reset();
g_texture_cache.reset(); g_vertex_manager.reset();
VertexShaderManager::Shutdown(); g_renderer.reset();
PixelShaderManager::Shutdown();
g_perf_query.reset();
g_vertex_manager.reset();
OpcodeDecoder::Shutdown();
g_renderer.reset();
}
} }
// This is called after Video_Initialize() from the Core // This is called after Video_Initialize() from the Core
void VideoSoftware::Video_Prepare() void VideoSoftware::Video_Prepare()
{ {
g_renderer = std::make_unique<SWRenderer>(); g_renderer = std::make_unique<SWRenderer>();
CommandProcessor::Init();
PixelEngine::Init();
BPInit();
g_vertex_manager = std::make_unique<SWVertexLoader>(); g_vertex_manager = std::make_unique<SWVertexLoader>();
g_perf_query = std::make_unique<PerfQuery>(); g_perf_query = std::make_unique<PerfQuery>();
Fifo::Init(); // must be done before OpcodeDecoder::Init()
OpcodeDecoder::Init();
IndexGenerator::Init();
VertexShaderManager::Init();
PixelShaderManager::Init();
g_texture_cache = std::make_unique<TextureCache>(); g_texture_cache = std::make_unique<TextureCache>();
SWRenderer::Init(); SWRenderer::Init();
VertexLoaderManager::Init();
g_framebuffer_manager = std::make_unique<FramebufferManager>(); g_framebuffer_manager = std::make_unique<FramebufferManager>();
// Notify the core that the video backend is ready
Host_Message(WM_USER_CREATE);
INFO_LOG(VIDEO, "Video backend initialized.");
} }
unsigned int VideoSoftware::PeekMessages() unsigned int VideoSoftware::PeekMessages()

View File

@ -25,7 +25,7 @@ class VideoSoftware : public VideoBackendBase
void Video_Prepare() override; void Video_Prepare() override;
void Video_Cleanup() override; void Video_Cleanup() override;
void ShowConfig(void* parent) override; void InitBackendInfo() override;
unsigned int PeekMessages() override; unsigned int PeekMessages() override;
}; };

View File

@ -453,10 +453,6 @@ void SetCPStatusFromCPU()
} }
} }
void Shutdown()
{
}
void SetCpStatusRegister() void SetCpStatusRegister()
{ {
// Here always there is one fifo attached to the GPU // Here always there is one fifo attached to the GPU

View File

@ -119,7 +119,6 @@ union UCPClearReg {
// Init // Init
void Init(); void Init();
void Shutdown();
void DoState(PointerWrap& p); void DoState(PointerWrap& p);
void RegisterMMIO(MMIO::Mapping* mmio, u32 base); void RegisterMMIO(MMIO::Mapping* mmio, u32 base);

View File

@ -30,10 +30,6 @@ void GeometryShaderManager::Init()
dirty = true; dirty = true;
} }
void GeometryShaderManager::Shutdown()
{
}
void GeometryShaderManager::Dirty() void GeometryShaderManager::Dirty()
{ {
// This function is called after a savestate is loaded. // This function is called after a savestate is loaded.

View File

@ -15,7 +15,6 @@ class GeometryShaderManager
public: public:
static void Init(); static void Init();
static void Dirty(); static void Dirty();
static void Shutdown();
static void DoState(PointerWrap& p); static void DoState(PointerWrap& p);
static void SetConstants(); static void SetConstants();

View File

@ -9,12 +9,23 @@
#include "Common/Event.h" #include "Common/Event.h"
#include "Common/Flag.h" #include "Common/Flag.h"
#include "Common/Logging/Log.h" #include "Common/Logging/Log.h"
#include "Core/ConfigManager.h"
#include "Core/Host.h"
#include "VideoCommon/AsyncRequests.h" #include "VideoCommon/AsyncRequests.h"
#include "VideoCommon/BPStructs.h" #include "VideoCommon/BPStructs.h"
#include "VideoCommon/CPMemory.h"
#include "VideoCommon/CommandProcessor.h"
#include "VideoCommon/Fifo.h" #include "VideoCommon/Fifo.h"
#include "VideoCommon/GeometryShaderManager.h"
#include "VideoCommon/IndexGenerator.h"
#include "VideoCommon/OnScreenDisplay.h"
#include "VideoCommon/OpcodeDecoding.h"
#include "VideoCommon/PixelEngine.h"
#include "VideoCommon/PixelShaderManager.h"
#include "VideoCommon/RenderBase.h" #include "VideoCommon/RenderBase.h"
#include "VideoCommon/TextureCacheBase.h" #include "VideoCommon/TextureCacheBase.h"
#include "VideoCommon/VertexLoaderManager.h" #include "VideoCommon/VertexLoaderManager.h"
#include "VideoCommon/VertexShaderManager.h"
#include "VideoCommon/VideoBackendBase.h" #include "VideoCommon/VideoBackendBase.h"
#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoConfig.h"
#include "VideoCommon/VideoState.h" #include "VideoCommon/VideoState.h"
@ -147,13 +158,65 @@ u16 VideoBackendBase::Video_GetBoundingBox(int index)
return result; return result;
} }
void VideoBackendBase::ShowConfig(void* parent_handle)
{
if (!m_initialized)
InitBackendInfo();
Host_ShowVideoConfig(parent_handle, GetDisplayName());
}
void VideoBackendBase::InitializeShared() void VideoBackendBase::InitializeShared()
{ {
VideoCommon_Init(); memset(&g_main_cp_state, 0, sizeof(g_main_cp_state));
memset(&g_preprocess_cp_state, 0, sizeof(g_preprocess_cp_state));
memset(texMem, 0, TMEM_SIZE);
// Do our OSD callbacks
OSD::DoCallbacks(OSD::CallbackType::Initialization);
// do not initialize again for the config window
m_initialized = true;
s_FifoShuttingDown.Clear(); s_FifoShuttingDown.Clear();
memset((void*)&s_beginFieldArgs, 0, sizeof(s_beginFieldArgs)); memset((void*)&s_beginFieldArgs, 0, sizeof(s_beginFieldArgs));
m_invalid = false; m_invalid = false;
frameCount = 0;
CommandProcessor::Init();
Fifo::Init();
OpcodeDecoder::Init();
PixelEngine::Init();
BPInit();
VertexLoaderManager::Init();
IndexGenerator::Init();
VertexShaderManager::Init();
GeometryShaderManager::Init();
PixelShaderManager::Init();
g_Config.Load(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini");
g_Config.GameIniLoad();
g_Config.UpdateProjectionHack();
g_Config.VerifyValidity();
UpdateActiveConfig();
// Notify the core that the video backend is ready
Host_Message(WM_USER_CREATE);
}
void VideoBackendBase::ShutdownShared()
{
// Do our OSD callbacks
OSD::DoCallbacks(OSD::CallbackType::Shutdown);
m_initialized = false;
Fifo::Shutdown();
}
void VideoBackendBase::CleanupShared()
{
VertexLoaderManager::Clear();
} }
// Run from the CPU thread // Run from the CPU thread

View File

@ -121,10 +121,6 @@ void Init()
s_bFifoErrorSeen = false; s_bFifoErrorSeen = false;
} }
void Shutdown()
{
}
template <bool is_preprocess> template <bool is_preprocess>
u8* Run(DataReader src, u32* cycles, bool in_display_list) u8* Run(DataReader src, u32* cycles, bool in_display_list)
{ {

View File

@ -42,7 +42,6 @@ class DataReader;
namespace OpcodeDecoder namespace OpcodeDecoder
{ {
void Init(); void Init();
void Shutdown();
template <bool is_preprocess = false> template <bool is_preprocess = false>
u8* Run(DataReader src, u32* cycles, bool in_display_list); u8* Run(DataReader src, u32* cycles, bool in_display_list);

View File

@ -56,10 +56,6 @@ void PixelShaderManager::Dirty()
dirty = true; dirty = true;
} }
void PixelShaderManager::Shutdown()
{
}
void PixelShaderManager::SetConstants() void PixelShaderManager::SetConstants()
{ {
if (s_bFogRangeAdjustChanged) if (s_bFogRangeAdjustChanged)

View File

@ -15,7 +15,6 @@ class PixelShaderManager
public: public:
static void Init(); static void Init();
static void Dirty(); static void Dirty();
static void Shutdown();
static void DoState(PointerWrap& p); static void DoState(PointerWrap& p);
static void SetConstants(); // sets pixel shader constants static void SetConstants(); // sets pixel shader constants

View File

@ -57,7 +57,7 @@ void Init()
SETSTAT(stats.numVertexLoaders, 0); SETSTAT(stats.numVertexLoaders, 0);
} }
void Shutdown() void Clear()
{ {
std::lock_guard<std::mutex> lk(s_vertex_loader_map_lock); std::lock_guard<std::mutex> lk(s_vertex_loader_map_lock);
s_vertex_loader_map.clear(); s_vertex_loader_map.clear();

View File

@ -20,7 +20,7 @@ using NativeVertexFormatMap =
std::unordered_map<PortableVertexDeclaration, std::unique_ptr<NativeVertexFormat>>; std::unordered_map<PortableVertexDeclaration, std::unique_ptr<NativeVertexFormat>>;
void Init(); void Init();
void Shutdown(); void Clear();
void MarkAllDirty(); void MarkAllDirty();

View File

@ -216,10 +216,6 @@ void VertexShaderManager::Init()
dirty = true; dirty = true;
} }
void VertexShaderManager::Shutdown()
{
}
void VertexShaderManager::Dirty() void VertexShaderManager::Dirty()
{ {
// This function is called after a savestate is loaded. // This function is called after a savestate is loaded.

View File

@ -19,7 +19,6 @@ class VertexShaderManager
public: public:
static void Init(); static void Init();
static void Dirty(); static void Dirty();
static void Shutdown();
static void DoState(PointerWrap& p); static void DoState(PointerWrap& p);
// constant management // constant management

View File

@ -73,7 +73,8 @@ public:
virtual std::string GetName() const = 0; virtual std::string GetName() const = 0;
virtual std::string GetDisplayName() const { return GetName(); } virtual std::string GetDisplayName() const { return GetName(); }
virtual void ShowConfig(void*) = 0; void ShowConfig(void*);
virtual void InitBackendInfo() = 0;
virtual void Video_Prepare() = 0; virtual void Video_Prepare() = 0;
void Video_ExitLoop(); void Video_ExitLoop();
@ -98,6 +99,8 @@ public:
protected: protected:
void InitializeShared(); void InitializeShared();
void ShutdownShared();
void CleanupShared();
bool m_initialized = false; bool m_initialized = false;
bool m_invalid = false; bool m_invalid = false;

View File

@ -65,10 +65,3 @@ void VideoCommon_DoState(PointerWrap& p)
// TODO: search for more data that should be saved and add it here // TODO: search for more data that should be saved and add it here
} }
void VideoCommon_Init()
{
memset(&g_main_cp_state, 0, sizeof(g_main_cp_state));
memset(&g_preprocess_cp_state, 0, sizeof(g_preprocess_cp_state));
memset(texMem, 0, TMEM_SIZE);
}

View File

@ -7,4 +7,3 @@
class PointerWrap; class PointerWrap;
void VideoCommon_DoState(PointerWrap& p); void VideoCommon_DoState(PointerWrap& p);
void VideoCommon_Init();

View File

@ -60,7 +60,7 @@ void Host_ConnectWiimote(int, bool)
void Host_SetWiiMoteConnectionState(int) void Host_SetWiiMoteConnectionState(int)
{ {
} }
void Host_ShowVideoConfig(void*, const std::string&, const std::string&) void Host_ShowVideoConfig(void*, const std::string&)
{ {
} }
std::unique_ptr<cInterfaceBase> HostGL_CreateGLInterface() std::unique_ptr<cInterfaceBase> HostGL_CreateGLInterface()