Don't set common globals from Video Backends

This commit is contained in:
Scott Mansell
2023-01-28 14:53:19 +13:00
parent d37f83ffeb
commit 58b70b2fb2
7 changed files with 65 additions and 35 deletions

View File

@ -71,14 +71,9 @@ void VideoBackend::InitBackendInfo()
bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
{
g_gfx = std::make_unique<NullGfx>();
g_renderer = std::make_unique<NullRenderer>();
g_bounding_box = std::make_unique<NullBoundingBox>();
g_vertex_manager = std::make_unique<VertexManager>();
g_perf_query = std::make_unique<PerfQuery>();
InitializeShared();
return true;
return InitializeShared(std::make_unique<NullGfx>(), std::make_unique<VertexManager>(),
std::make_unique<PerfQuery>(), std::make_unique<NullBoundingBox>(),
std::make_unique<NullRenderer>(), std::make_unique<TextureCache>());
}
void VideoBackend::Shutdown()

View File

@ -187,17 +187,16 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
if (!InitializeGLExtensions(main_gl_context.get()) || !FillBackendInfo())
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();
g_vertex_manager = std::make_unique<VertexManager>();
g_perf_query = GetPerfQuery();
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()

View File

@ -15,9 +15,8 @@
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"))
return std::make_unique<PerfQueryGLESNV>();
else if (is_gles)

View File

@ -12,7 +12,7 @@
namespace OGL
{
std::unique_ptr<PerfQueryBase> GetPerfQuery();
std::unique_ptr<PerfQueryBase> GetPerfQuery(bool is_gles);
class PerfQuery : public PerfQueryBase
{

View File

@ -106,14 +106,10 @@ bool VideoSoftware::Initialize(const WindowSystemInfo& wsi)
Clipper::Init();
Rasterizer::Init();
g_gfx = std::make_unique<SWGfx>(std::move(window));
g_bounding_box = std::make_unique<SWBoundingBox>();
g_vertex_manager = std::make_unique<SWVertexLoader>();
g_perf_query = std::make_unique<PerfQuery>();
InitializeShared();
return true;
return InitializeShared(std::make_unique<SWGfx>(std::move(window)),
std::make_unique<SWVertexLoader>(), std::make_unique<PerfQuery>(),
std::make_unique<SWBoundingBox>(), std::make_unique<SWRenderer>(),
std::make_unique<TextureCache>());
}
void VideoSoftware::Shutdown()