Permalink
Browse files

Renderer: Add a base Initialize() method to match Shutdown()

  • Loading branch information...
stenzek committed Feb 9, 2018
1 parent 38479dd commit 1adcd47dcbd80e0435d42e61dab3f00a22d1ca38
@@ -161,7 +161,8 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
D3D::InitUtils();
BBox::Init();
return true;
return g_renderer->Initialize();
}
void VideoBackend::Shutdown()
@@ -64,7 +64,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
g_framebuffer_manager = std::make_unique<FramebufferManagerBase>();
g_texture_cache = std::make_unique<TextureCache>();
g_shader_cache = std::make_unique<VideoCommon::ShaderCache>();
return g_shader_cache->Initialize();
return g_renderer->Initialize() && g_shader_cache->Initialize();
}
void VideoBackend::Shutdown()
@@ -811,19 +811,11 @@ bool Renderer::IsHeadless() const
return m_main_gl_context->IsHeadless();
}
void Renderer::Shutdown()
bool Renderer::Initialize()
{
::Renderer::Shutdown();
g_framebuffer_manager.reset();
if (!::Renderer::Initialize())
return false;
UpdateActiveConfig();
s_raster_font.reset();
m_post_processor.reset();
}
void Renderer::Init()
{
// Initialize the FramebufferManager
g_framebuffer_manager = std::make_unique<FramebufferManager>(
m_target_width, m_target_height, s_MSAASamples, BoundingBox::NeedsStencilBuffer());
@@ -832,6 +824,19 @@ void Renderer::Init()
m_post_processor = std::make_unique<OpenGLPostProcessing>();
s_raster_font = std::make_unique<RasterFont>();
return true;
}
void Renderer::Shutdown()
{
::Renderer::Shutdown();
g_framebuffer_manager.reset();
UpdateActiveConfig();
s_raster_font.reset();
m_post_processor.reset();
}
std::unique_ptr<AbstractTexture> Renderer::CreateTexture(const TextureConfig& config)
@@ -88,7 +88,7 @@ class Renderer : public ::Renderer
bool IsHeadless() const override;
void Init();
bool Initialize() override;
void Shutdown() override;
std::unique_ptr<AbstractTexture> CreateTexture(const TextureConfig& config) override;
@@ -179,7 +179,8 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
g_texture_cache = std::make_unique<TextureCache>();
g_sampler_cache = std::make_unique<SamplerCache>();
g_shader_cache = std::make_unique<VideoCommon::ShaderCache>();
static_cast<Renderer*>(g_renderer.get())->Init();
if (!g_renderer->Initialize())
return false;
TextureConverter::Init();
BoundingBox::Init(g_renderer->GetTargetWidth(), g_renderer->GetTargetHeight());
return g_shader_cache->Initialize();
@@ -95,7 +95,7 @@ bool VideoSoftware::Initialize(const WindowSystemInfo& wsi)
g_perf_query = std::make_unique<PerfQuery>();
g_texture_cache = std::make_unique<TextureCache>();
g_shader_cache = std::make_unique<VideoCommon::ShaderCache>();
return g_shader_cache->Initialize();
return g_renderer->Initialize() && g_shader_cache->Initialize();
}
void VideoSoftware::Shutdown()
@@ -57,13 +57,7 @@ Renderer::Renderer(std::unique_ptr<SwapChain> swap_chain)
m_sampler_states[i].hex = RenderState::GetPointSamplerState().hex;
}
Renderer::~Renderer()
{
UpdateActiveConfig();
DestroyShaders();
DestroySemaphores();
}
Renderer::~Renderer() = default;
Renderer* Renderer::GetInstance()
{
@@ -77,6 +71,9 @@ bool Renderer::IsHeadless() const
bool Renderer::Initialize()
{
if (!::Renderer::Initialize())
return false;
BindEFBToStateTracker();
if (!CreateSemaphores())
@@ -131,6 +128,18 @@ bool Renderer::Initialize()
return true;
}
void Renderer::Shutdown()
{
::Renderer::Shutdown();
// Submit the current command buffer, in case there's a partial frame.
StateTracker::GetInstance()->EndRenderPass();
g_command_buffer_mgr->ExecuteCommandBuffer(false, true);
DestroyShaders();
DestroySemaphores();
}
bool Renderer::CreateSemaphores()
{
// Create two semaphores, one that is triggered when the swapchain buffer is ready, another after
@@ -37,6 +37,9 @@ class Renderer : public ::Renderer
bool IsHeadless() const override;
bool Initialize() override;
void Shutdown() override;
std::unique_ptr<AbstractTexture> CreateTexture(const TextureConfig& config) override;
std::unique_ptr<AbstractStagingTexture>
CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override;
@@ -52,8 +55,6 @@ class Renderer : public ::Renderer
SwapChain* GetSwapChain() const { return m_swap_chain.get(); }
BoundingBox* GetBoundingBox() const { return m_bounding_box.get(); }
bool Initialize();
void RenderText(const std::string& pstr, int left, int top, u32 color) override;
u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) override;
void PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points) override;
@@ -93,6 +93,11 @@ Renderer::Renderer(int backbuffer_width, int backbuffer_height)
Renderer::~Renderer() = default;
bool Renderer::Initialize()
{
return true;
}
void Renderer::Shutdown()
{
// First stop any framedumping, which might need to dump the last xfb frame. This process
@@ -79,6 +79,9 @@ class Renderer
virtual bool IsHeadless() const = 0;
virtual bool Initialize();
virtual void Shutdown();
virtual void SetPipeline(const AbstractPipeline* pipeline) {}
virtual void SetScissorRect(const MathUtil::Rectangle<int>& rc) {}
virtual void SetTexture(u32 index, const AbstractTexture* texture) {}
@@ -188,8 +191,6 @@ class Renderer
virtual std::unique_ptr<VideoCommon::AsyncShaderCompiler> CreateAsyncShaderCompiler();
virtual void Shutdown();
// Drawing utility shaders.
virtual void DrawUtilityPipeline(const void* uniforms, u32 uniforms_size, const void* vertices,
u32 vertex_stride, u32 num_vertices)

0 comments on commit 1adcd47

Please sign in to comment.