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

This commit is contained in:
Stenzek
2018-02-09 20:52:25 +10:00
parent 38479dd783
commit 1adcd47dcb
10 changed files with 51 additions and 28 deletions

View File

@ -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

View File

@ -37,6 +37,9 @@ public:
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 @@ public:
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;