mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-24 14:49:42 -06: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:
@ -2,10 +2,11 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <memory>
|
||||
#include "VideoCommon/PerfQueryBase.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
PerfQueryBase* g_perf_query = nullptr;
|
||||
std::unique_ptr<PerfQueryBase> g_perf_query;
|
||||
|
||||
bool PerfQueryBase::ShouldEmulate()
|
||||
{
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
enum PerfQueryType
|
||||
@ -65,4 +66,4 @@ protected:
|
||||
volatile u32 m_results[PQG_NUM_MEMBERS];
|
||||
};
|
||||
|
||||
extern PerfQueryBase* g_perf_query;
|
||||
extern std::unique_ptr<PerfQueryBase> g_perf_query;
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cmath>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/Atomic.h"
|
||||
@ -51,7 +52,7 @@ int frameCount;
|
||||
int OSDChoice;
|
||||
static int OSDTime;
|
||||
|
||||
Renderer *g_renderer = nullptr;
|
||||
std::unique_ptr<Renderer> g_renderer;
|
||||
|
||||
std::mutex Renderer::s_criticalScreenshot;
|
||||
std::string Renderer::s_sScreenshotName;
|
||||
|
@ -14,6 +14,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
|
||||
@ -182,5 +183,5 @@ private:
|
||||
static unsigned int efb_scale_denominatorY;
|
||||
};
|
||||
|
||||
extern Renderer *g_renderer;
|
||||
extern std::unique_ptr<Renderer> g_renderer;
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
@ -28,7 +29,7 @@ static const int TEXTURE_KILL_THRESHOLD = 64; // Sonic the Fighters (inside Soni
|
||||
static const int TEXTURE_POOL_KILL_THRESHOLD = 3;
|
||||
static const int FRAMECOUNT_INVALID = 0;
|
||||
|
||||
TextureCacheBase* g_texture_cache;
|
||||
std::unique_ptr<TextureCacheBase> g_texture_cache;
|
||||
|
||||
alignas(16) u8* TextureCacheBase::temp = nullptr;
|
||||
size_t TextureCacheBase::temp_size;
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
@ -179,4 +180,4 @@ private:
|
||||
} backup_config;
|
||||
};
|
||||
|
||||
extern TextureCacheBase* g_texture_cache;
|
||||
extern std::unique_ptr<TextureCacheBase> g_texture_cache;
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "Common/CommonTypes.h"
|
||||
|
||||
#include "VideoCommon/BPStructs.h"
|
||||
@ -22,7 +24,7 @@
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
#include "VideoCommon/XFMemory.h"
|
||||
|
||||
VertexManagerBase* g_vertex_manager;
|
||||
std::unique_ptr<VertexManagerBase> g_vertex_manager;
|
||||
|
||||
u8* VertexManagerBase::s_pCurBufferPointer;
|
||||
u8* VertexManagerBase::s_pBaseBufferPointer;
|
||||
|
@ -4,7 +4,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "Common/CommonFuncs.h"
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "VideoCommon/DataReader.h"
|
||||
@ -82,4 +84,4 @@ private:
|
||||
virtual void DestroyDeviceObjects() {}
|
||||
};
|
||||
|
||||
extern VertexManagerBase* g_vertex_manager;
|
||||
extern std::unique_ptr<VertexManagerBase> g_vertex_manager;
|
||||
|
Reference in New Issue
Block a user