mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 12:19:12 +00:00
VideoBackends: Simplify initialization and deinitialization of resources
Approximately three or four times now, the issue of pointers being in an inconsistent state been an issue in the video backend renderers with regards to tripping up other developers. Global (ugh) resources are put into a unique_ptr and will always have a well-defined state of being - null or not null
This commit is contained in:
parent
1fbab188ad
commit
f295182833
25 changed files with 104 additions and 86 deletions
|
@ -38,6 +38,7 @@ Make AA apply instantly during gameplay if possible
|
|||
|
||||
#include <algorithm>
|
||||
#include <cstdarg>
|
||||
#include <memory>
|
||||
|
||||
#include "Common/Atomic.h"
|
||||
#include "Common/CommonPaths.h"
|
||||
|
@ -182,13 +183,13 @@ void VideoBackend::Video_Prepare()
|
|||
{
|
||||
GLInterface->MakeCurrent();
|
||||
|
||||
g_renderer = new Renderer;
|
||||
g_renderer = std::make_unique<Renderer>();
|
||||
|
||||
CommandProcessor::Init();
|
||||
PixelEngine::Init();
|
||||
|
||||
BPInit();
|
||||
g_vertex_manager = new VertexManager;
|
||||
g_vertex_manager = std::make_unique<VertexManager>();
|
||||
g_perf_query = GetPerfQuery();
|
||||
Fifo_Init(); // must be done before OpcodeDecoder_Init()
|
||||
OpcodeDecoder_Init();
|
||||
|
@ -197,8 +198,8 @@ void VideoBackend::Video_Prepare()
|
|||
PixelShaderManager::Init();
|
||||
GeometryShaderManager::Init();
|
||||
ProgramShaderCache::Init();
|
||||
g_texture_cache = new TextureCache();
|
||||
g_sampler_cache = new SamplerCache();
|
||||
g_texture_cache = std::make_unique<TextureCache>();
|
||||
g_sampler_cache = std::make_unique<SamplerCache>();
|
||||
Renderer::Init();
|
||||
VertexLoaderManager::Init();
|
||||
TextureConverter::Init();
|
||||
|
@ -216,39 +217,35 @@ void VideoBackend::Shutdown()
|
|||
OSD::DoCallbacks(OSD::OSD_SHUTDOWN);
|
||||
|
||||
GLInterface->Shutdown();
|
||||
delete GLInterface;
|
||||
GLInterface = nullptr;
|
||||
GLInterface.reset();
|
||||
}
|
||||
|
||||
void VideoBackend::Video_Cleanup()
|
||||
{
|
||||
if (g_renderer)
|
||||
{
|
||||
Fifo_Shutdown();
|
||||
if (!g_renderer)
|
||||
return;
|
||||
|
||||
// The following calls are NOT Thread Safe
|
||||
// And need to be called from the video thread
|
||||
Renderer::Shutdown();
|
||||
BoundingBox::Shutdown();
|
||||
TextureConverter::Shutdown();
|
||||
VertexLoaderManager::Shutdown();
|
||||
delete g_sampler_cache;
|
||||
g_sampler_cache = nullptr;
|
||||
delete g_texture_cache;
|
||||
g_texture_cache = nullptr;
|
||||
ProgramShaderCache::Shutdown();
|
||||
VertexShaderManager::Shutdown();
|
||||
PixelShaderManager::Shutdown();
|
||||
GeometryShaderManager::Shutdown();
|
||||
delete g_perf_query;
|
||||
g_perf_query = nullptr;
|
||||
delete g_vertex_manager;
|
||||
g_vertex_manager = nullptr;
|
||||
OpcodeDecoder_Shutdown();
|
||||
delete g_renderer;
|
||||
g_renderer = nullptr;
|
||||
GLInterface->ClearCurrent();
|
||||
}
|
||||
Fifo_Shutdown();
|
||||
|
||||
// The following calls are NOT Thread Safe
|
||||
// And need to be called from the video thread
|
||||
Renderer::Shutdown();
|
||||
BoundingBox::Shutdown();
|
||||
TextureConverter::Shutdown();
|
||||
VertexLoaderManager::Shutdown();
|
||||
g_sampler_cache.reset();
|
||||
g_texture_cache.reset();
|
||||
ProgramShaderCache::Shutdown();
|
||||
VertexShaderManager::Shutdown();
|
||||
PixelShaderManager::Shutdown();
|
||||
GeometryShaderManager::Shutdown();
|
||||
|
||||
g_perf_query.reset();
|
||||
g_vertex_manager.reset();
|
||||
|
||||
OpcodeDecoder_Shutdown();
|
||||
g_renderer.reset();
|
||||
GLInterface->ClearCurrent();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue