mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-24 23:11:14 +01:00
Don't set common globals from Video Backends
This commit is contained in:
parent
d37f83ffeb
commit
58b70b2fb2
@ -71,14 +71,9 @@ void VideoBackend::InitBackendInfo()
|
|||||||
|
|
||||||
bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||||
{
|
{
|
||||||
g_gfx = std::make_unique<NullGfx>();
|
return InitializeShared(std::make_unique<NullGfx>(), std::make_unique<VertexManager>(),
|
||||||
g_renderer = std::make_unique<NullRenderer>();
|
std::make_unique<PerfQuery>(), std::make_unique<NullBoundingBox>(),
|
||||||
g_bounding_box = std::make_unique<NullBoundingBox>();
|
std::make_unique<NullRenderer>(), std::make_unique<TextureCache>());
|
||||||
g_vertex_manager = std::make_unique<VertexManager>();
|
|
||||||
g_perf_query = std::make_unique<PerfQuery>();
|
|
||||||
|
|
||||||
InitializeShared();
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoBackend::Shutdown()
|
void VideoBackend::Shutdown()
|
||||||
|
@ -187,17 +187,16 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
|||||||
if (!InitializeGLExtensions(main_gl_context.get()) || !FillBackendInfo())
|
if (!InitializeGLExtensions(main_gl_context.get()) || !FillBackendInfo())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
g_gfx = std::make_unique<OGLGfx>(std::move(main_gl_context), wsi.render_surface_scale);
|
auto gfx = std::make_unique<OGLGfx>(std::move(main_gl_context), wsi.render_surface_scale);
|
||||||
ProgramShaderCache::Init();
|
ProgramShaderCache::Init();
|
||||||
|
|
||||||
g_vertex_manager = std::make_unique<VertexManager>();
|
|
||||||
g_perf_query = GetPerfQuery();
|
|
||||||
g_sampler_cache = std::make_unique<SamplerCache>();
|
g_sampler_cache = std::make_unique<SamplerCache>();
|
||||||
g_bounding_box = std::make_unique<OGLBoundingBox>();
|
|
||||||
|
|
||||||
InitializeShared();
|
auto vertex_manager = std::make_unique<VertexManager>();
|
||||||
|
auto perf_query = GetPerfQuery(gfx->IsGLES());
|
||||||
|
auto bounding_box = std::make_unique<OGLBoundingBox>();
|
||||||
|
|
||||||
return true;
|
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||||
|
std::move(bounding_box));
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoBackend::Shutdown()
|
void VideoBackend::Shutdown()
|
||||||
|
@ -15,9 +15,8 @@
|
|||||||
|
|
||||||
namespace OGL
|
namespace OGL
|
||||||
{
|
{
|
||||||
std::unique_ptr<PerfQueryBase> GetPerfQuery()
|
std::unique_ptr<PerfQueryBase> GetPerfQuery(bool is_gles)
|
||||||
{
|
{
|
||||||
const bool is_gles = static_cast<OGLGfx*>(g_gfx.get())->IsGLES();
|
|
||||||
if (is_gles && GLExtensions::Supports("GL_NV_occlusion_query_samples"))
|
if (is_gles && GLExtensions::Supports("GL_NV_occlusion_query_samples"))
|
||||||
return std::make_unique<PerfQueryGLESNV>();
|
return std::make_unique<PerfQueryGLESNV>();
|
||||||
else if (is_gles)
|
else if (is_gles)
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
namespace OGL
|
namespace OGL
|
||||||
{
|
{
|
||||||
std::unique_ptr<PerfQueryBase> GetPerfQuery();
|
std::unique_ptr<PerfQueryBase> GetPerfQuery(bool is_gles);
|
||||||
|
|
||||||
class PerfQuery : public PerfQueryBase
|
class PerfQuery : public PerfQueryBase
|
||||||
{
|
{
|
||||||
|
@ -106,14 +106,10 @@ bool VideoSoftware::Initialize(const WindowSystemInfo& wsi)
|
|||||||
Clipper::Init();
|
Clipper::Init();
|
||||||
Rasterizer::Init();
|
Rasterizer::Init();
|
||||||
|
|
||||||
g_gfx = std::make_unique<SWGfx>(std::move(window));
|
return InitializeShared(std::make_unique<SWGfx>(std::move(window)),
|
||||||
g_bounding_box = std::make_unique<SWBoundingBox>();
|
std::make_unique<SWVertexLoader>(), std::make_unique<PerfQuery>(),
|
||||||
g_vertex_manager = std::make_unique<SWVertexLoader>();
|
std::make_unique<SWBoundingBox>(), std::make_unique<SWRenderer>(),
|
||||||
g_perf_query = std::make_unique<PerfQuery>();
|
std::make_unique<TextureCache>());
|
||||||
|
|
||||||
InitializeShared();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoSoftware::Shutdown()
|
void VideoSoftware::Shutdown()
|
||||||
|
@ -317,7 +317,25 @@ void VideoBackendBase::DoState(PointerWrap& p)
|
|||||||
system.GetFifo().GpuMaySleep();
|
system.GetFifo().GpuMaySleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoBackendBase::InitializeShared()
|
bool VideoBackendBase::InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||||
|
std::unique_ptr<VertexManagerBase> vertex_manager,
|
||||||
|
std::unique_ptr<PerfQueryBase> perf_query,
|
||||||
|
std::unique_ptr<BoundingBox> bounding_box)
|
||||||
|
{
|
||||||
|
// All hardware backends use the default RendererBase and TextureCacheBase.
|
||||||
|
// Only Null and Software backends override them
|
||||||
|
|
||||||
|
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||||
|
std::move(bounding_box), std::make_unique<Renderer>(),
|
||||||
|
std::make_unique<TextureCacheBase>());
|
||||||
|
}
|
||||||
|
|
||||||
|
bool VideoBackendBase::InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||||
|
std::unique_ptr<VertexManagerBase> vertex_manager,
|
||||||
|
std::unique_ptr<PerfQueryBase> perf_query,
|
||||||
|
std::unique_ptr<BoundingBox> bounding_box,
|
||||||
|
std::unique_ptr<Renderer> renderer,
|
||||||
|
std::unique_ptr<TextureCacheBase> texture_cache)
|
||||||
{
|
{
|
||||||
memset(reinterpret_cast<u8*>(&g_main_cp_state), 0, sizeof(g_main_cp_state));
|
memset(reinterpret_cast<u8*>(&g_main_cp_state), 0, sizeof(g_main_cp_state));
|
||||||
memset(reinterpret_cast<u8*>(&g_preprocess_cp_state), 0, sizeof(g_preprocess_cp_state));
|
memset(reinterpret_cast<u8*>(&g_preprocess_cp_state), 0, sizeof(g_preprocess_cp_state));
|
||||||
@ -326,14 +344,17 @@ void VideoBackendBase::InitializeShared()
|
|||||||
// do not initialize again for the config window
|
// do not initialize again for the config window
|
||||||
m_initialized = true;
|
m_initialized = true;
|
||||||
|
|
||||||
if (!g_renderer)
|
g_gfx = std::move(gfx);
|
||||||
{
|
g_vertex_manager = std::move(vertex_manager);
|
||||||
// Null and Software Backends supply their own Renderer
|
g_perf_query = std::move(perf_query);
|
||||||
g_renderer = std::make_unique<Renderer>();
|
g_bounding_box = std::move(bounding_box);
|
||||||
}
|
|
||||||
|
// Null and Software Backends supply their own derived Renderer and Texture Cache
|
||||||
|
g_texture_cache = std::move(texture_cache);
|
||||||
|
g_renderer = std::move(renderer);
|
||||||
|
|
||||||
g_presenter = std::make_unique<VideoCommon::Presenter>();
|
g_presenter = std::make_unique<VideoCommon::Presenter>();
|
||||||
g_frame_dumper = std::make_unique<FrameDumper>();
|
g_frame_dumper = std::make_unique<FrameDumper>();
|
||||||
g_texture_cache = std::make_unique<TextureCacheBase>();
|
|
||||||
g_framebuffer_manager = std::make_unique<FramebufferManager>();
|
g_framebuffer_manager = std::make_unique<FramebufferManager>();
|
||||||
g_shader_cache = std::make_unique<VideoCommon::ShaderCache>();
|
g_shader_cache = std::make_unique<VideoCommon::ShaderCache>();
|
||||||
|
|
||||||
@ -355,13 +376,15 @@ void VideoBackendBase::InitializeShared()
|
|||||||
{
|
{
|
||||||
PanicAlertFmtT("Failed to initialize renderer classes");
|
PanicAlertFmtT("Failed to initialize renderer classes");
|
||||||
Shutdown();
|
Shutdown();
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_Config.VerifyValidity();
|
g_Config.VerifyValidity();
|
||||||
UpdateActiveConfig();
|
UpdateActiveConfig();
|
||||||
|
|
||||||
g_shader_cache->InitializeShaderCache();
|
g_shader_cache->InitializeShaderCache();
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VideoBackendBase::ShutdownShared()
|
void VideoBackendBase::ShutdownShared()
|
||||||
|
@ -18,6 +18,12 @@ class Mapping;
|
|||||||
}
|
}
|
||||||
class PointerWrap;
|
class PointerWrap;
|
||||||
|
|
||||||
|
class AbstractGfx;
|
||||||
|
class BoundingBox;
|
||||||
|
class Renderer;
|
||||||
|
class TextureCacheBase;
|
||||||
|
class VertexManagerBase;
|
||||||
|
|
||||||
enum class FieldType
|
enum class FieldType
|
||||||
{
|
{
|
||||||
Odd,
|
Odd,
|
||||||
@ -71,7 +77,19 @@ public:
|
|||||||
void DoState(PointerWrap& p);
|
void DoState(PointerWrap& p);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void InitializeShared();
|
// For hardware backends
|
||||||
|
bool InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||||
|
std::unique_ptr<VertexManagerBase> vertex_manager,
|
||||||
|
std::unique_ptr<PerfQueryBase> perf_query,
|
||||||
|
std::unique_ptr<BoundingBox> bounding_box);
|
||||||
|
|
||||||
|
// For software and null backends. Allows overriding the default Renderer and Texture Cache
|
||||||
|
bool InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||||
|
std::unique_ptr<VertexManagerBase> vertex_manager,
|
||||||
|
std::unique_ptr<PerfQueryBase> perf_query,
|
||||||
|
std::unique_ptr<BoundingBox> bounding_box,
|
||||||
|
std::unique_ptr<Renderer> renderer,
|
||||||
|
std::unique_ptr<TextureCacheBase> texture_cache);
|
||||||
void ShutdownShared();
|
void ShutdownShared();
|
||||||
|
|
||||||
bool m_initialized = false;
|
bool m_initialized = false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user