Skip to content

Commit

Permalink
Merge pull request #3510 from degasus/master
Browse files Browse the repository at this point in the history
VideoBackends: Merge backend initialization and shutdown.
  • Loading branch information
degasus committed Jun 26, 2016
2 parents b16333a + d79aeaa commit 3887328
Show file tree
Hide file tree
Showing 37 changed files with 160 additions and 352 deletions.
2 changes: 1 addition & 1 deletion Source/Android/jni/MainAndroid.cpp
Expand Up @@ -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&)
{
}

Expand Down
3 changes: 1 addition & 2 deletions Source/Core/Core/Host.h
Expand Up @@ -37,8 +37,7 @@ void Host_SetWiiMoteConnectionState(int _State);
void Host_UpdateDisasmDialog();
void Host_UpdateMainFrame();
void Host_UpdateTitle(const std::string& title);
void Host_ShowVideoConfig(void* parent, const std::string& backend_name,
const std::string& config_name);
void Host_ShowVideoConfig(void* parent, const std::string& backend_name);

// TODO (neobrain): Remove this from host!
void* Host_GetRenderHandle();
3 changes: 1 addition & 2 deletions Source/Core/DolphinQt2/Host.cpp
Expand Up @@ -121,8 +121,7 @@ void Host_SetWiiMoteConnectionState(int state)
void Host_ConnectWiimote(int wm_idx, bool connect)
{
}
void Host_ShowVideoConfig(void* parent, const std::string& backend_name,
const std::string& config_name)
void Host_ShowVideoConfig(void* parent, const std::string& backend_name)
{
}
void Host_RefreshDSPDebuggerWindow()
Expand Down
7 changes: 3 additions & 4 deletions Source/Core/DolphinWX/Main.cpp
Expand Up @@ -555,17 +555,16 @@ void Host_ConnectWiimote(int wm_idx, bool connect)
}
}

void Host_ShowVideoConfig(void* parent, const std::string& backend_name,
const std::string& config_name)
void Host_ShowVideoConfig(void* parent, const std::string& backend_name)
{
if (backend_name == "Software Renderer")
{
SoftwareVideoConfigDialog diag((wxWindow*)parent, backend_name, config_name);
SoftwareVideoConfigDialog diag((wxWindow*)parent, backend_name);
diag.ShowModal();
}
else
{
VideoConfigDiag diag((wxWindow*)parent, backend_name, config_name);
VideoConfigDiag diag((wxWindow*)parent, backend_name);
diag.ShowModal();
}
}
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/MainNoGUI.cpp
Expand Up @@ -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&)
{
}

Expand Down
8 changes: 2 additions & 6 deletions Source/Core/DolphinWX/SoftwareVideoConfigDialog.cpp
Expand Up @@ -31,17 +31,13 @@ IntegerSetting<T>::IntegerSetting(wxWindow* parent, const wxString& label, T& se
Bind(wxEVT_SPINCTRL, &IntegerSetting::UpdateValue, this);
}

SoftwareVideoConfigDialog::SoftwareVideoConfigDialog(wxWindow* parent, const std::string& title,
const std::string& ininame)
SoftwareVideoConfigDialog::SoftwareVideoConfigDialog(wxWindow* parent, const std::string& title)
: wxDialog(parent, wxID_ANY,
wxString(wxString::Format(_("Dolphin %s Graphics Configuration"), title)))
{
VideoConfig& vconfig = g_Config;

if (File::Exists(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");
vconfig.Load(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini");

wxNotebook* const notebook = new wxNotebook(this, wxID_ANY);

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/SoftwareVideoConfigDialog.h
Expand Up @@ -19,7 +19,7 @@
class SoftwareVideoConfigDialog : public wxDialog
{
public:
SoftwareVideoConfigDialog(wxWindow* parent, const std::string& title, const std::string& ininame);
SoftwareVideoConfigDialog(wxWindow* parent, const std::string& title);
~SoftwareVideoConfigDialog();

void Event_Backend(wxCommandEvent& ev)
Expand Down
8 changes: 2 additions & 6 deletions Source/Core/DolphinWX/VideoConfigDiag.cpp
Expand Up @@ -329,16 +329,12 @@ static wxArrayString GetListOfResolutions()
}
#endif

VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title,
const std::string& ininame)
VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string& title)
: wxDialog(parent, wxID_ANY, wxString::Format(_("Dolphin %s Graphics Configuration"),
wxGetTranslation(StrToWxStr(title)))),
vconfig(g_Config)
{
if (File::Exists(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");
vconfig.Load(File::GetUserPath(D_CONFIG_IDX) + "GFX.ini");

Bind(wxEVT_UPDATE_UI, &VideoConfigDiag::OnUpdateUI, this);

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/DolphinWX/VideoConfigDiag.h
Expand Up @@ -83,7 +83,7 @@ class SettingChoice : public wxChoice
class VideoConfigDiag : public wxDialog
{
public:
VideoConfigDiag(wxWindow* parent, const std::string& title, const std::string& ininame);
VideoConfigDiag(wxWindow* parent, const std::string& title);

protected:
void Event_Backend(wxCommandEvent& ev)
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/D3D/VideoBackend.h
Expand Up @@ -20,7 +20,7 @@ class VideoBackend : public VideoBackendBase
void Video_Prepare() override;
void Video_Cleanup() override;

void ShowConfig(void* parent) override;
void InitBackendInfo() override;

unsigned int PeekMessages() override;

Expand Down
77 changes: 15 additions & 62 deletions Source/Core/VideoBackends/D3D/main.cpp
Expand Up @@ -61,7 +61,7 @@ std::string VideoBackend::GetDisplayName() const
return "Direct3D 11";
}

void InitBackendInfo()
void VideoBackend::InitBackendInfo()
{
HRESULT hr = DX11::D3D::LoadDXGI();
if (SUCCEEDED(hr))
Expand Down Expand Up @@ -138,34 +138,15 @@ void InitBackendInfo()
DX11::D3D::UnloadD3D();
}

void VideoBackend::ShowConfig(void* hParent)
{
InitBackendInfo();
Host_ShowVideoConfig(hParent, GetDisplayName(), "gfx_dx11");
}

bool VideoBackend::Initialize(void* window_handle)
{
if (window_handle == nullptr)
return false;

InitializeShared();
InitBackendInfo();

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();
InitializeShared();

m_window_handle = window_handle;
m_initialized = true;

return true;
}
Expand All @@ -181,55 +162,27 @@ void VideoBackend::Video_Prepare()
PixelShaderCache::Init();
GeometryShaderCache::Init();
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()
{
m_initialized = false;

// TODO: should be in Video_Cleanup
if (g_renderer)
{
// VideoCommon
Fifo::Shutdown();
CommandProcessor::Shutdown();
GeometryShaderManager::Shutdown();
PixelShaderManager::Shutdown();
VertexShaderManager::Shutdown();
OpcodeDecoder::Shutdown();
VertexLoaderManager::Shutdown();

// internal interfaces
D3D::ShutdownUtils();
PixelShaderCache::Shutdown();
VertexShaderCache::Shutdown();
GeometryShaderCache::Shutdown();
BBox::Shutdown();

g_perf_query.reset();
g_vertex_manager.reset();
g_texture_cache.reset();
g_renderer.reset();
}
D3D::ShutdownUtils();
PixelShaderCache::Shutdown();
VertexShaderCache::Shutdown();
GeometryShaderCache::Shutdown();
BBox::Shutdown();

g_perf_query.reset();
g_vertex_manager.reset();
g_texture_cache.reset();
g_renderer.reset();

ShutdownShared();
}

void VideoBackend::Video_Cleanup()
{
CleanupShared();
}
}
2 changes: 1 addition & 1 deletion Source/Core/VideoBackends/D3D12/VideoBackend.h
Expand Up @@ -20,7 +20,7 @@ class VideoBackend : public VideoBackendBase
void Video_Prepare() override;
void Video_Cleanup() override;

void ShowConfig(void* parent) override;
void InitBackendInfo() override;

unsigned int PeekMessages() override;

Expand Down
93 changes: 24 additions & 69 deletions Source/Core/VideoBackends/D3D12/main.cpp
Expand Up @@ -62,7 +62,7 @@ std::string VideoBackend::GetDisplayName() const
return "Direct3D 12 (experimental)";
}

void InitBackendInfo()
void VideoBackend::InitBackendInfo()
{
HRESULT hr = D3D::LoadDXGI();
if (FAILED(hr))
Expand Down Expand Up @@ -152,37 +152,18 @@ void InitBackendInfo()
D3D::UnloadDXGI();
}

void VideoBackend::ShowConfig(void* hParent)
{
InitBackendInfo();
Host_ShowVideoConfig(hParent, GetDisplayName(), "gfx_dx12");
}

bool VideoBackend::Initialize(void* window_handle)
{
if (window_handle == nullptr)
return false;

InitializeShared();
InitBackendInfo();

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();
InitializeShared();

if (FAILED(D3D::Create((HWND)window_handle)))
return false;

m_window_handle = window_handle;
m_initialized = true;

return true;
}
Expand All @@ -200,62 +181,36 @@ void VideoBackend::Video_Prepare()
StaticShaderCache::Init();
StateCache::Init(); // PSO cache is populated here, after constituent shaders are loaded.
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()
{
m_initialized = true;

// 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
Fifo::Shutdown();
CommandProcessor::Shutdown();
GeometryShaderManager::Shutdown();
PixelShaderManager::Shutdown();
VertexShaderManager::Shutdown();
OpcodeDecoder::Shutdown();
VertexLoaderManager::Shutdown();

// internal interfaces
D3D::ShutdownUtils();
ShaderCache::Shutdown();
ShaderConstantsManager::Shutdown();
StaticShaderCache::Shutdown();
BBox::Shutdown();

g_xfb_encoder.reset();
g_perf_query.reset();
g_vertex_manager.reset();
g_texture_cache.reset();
g_renderer.reset();

D3D::Close();
}

// 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);

// internal interfaces
D3D::ShutdownUtils();
ShaderCache::Shutdown();
ShaderConstantsManager::Shutdown();
StaticShaderCache::Shutdown();
BBox::Shutdown();

g_xfb_encoder.reset();
g_perf_query.reset();
g_vertex_manager.reset();
g_texture_cache.reset();
g_renderer.reset();

D3D::Close();

ShutdownShared();
}

void VideoBackend::Video_Cleanup()
{
CleanupShared();
}
}

0 comments on commit 3887328

Please sign in to comment.