diff --git a/Source/Core/VideoBackends/D3D/Render.cpp b/Source/Core/VideoBackends/D3D/Render.cpp index 970a7e5bea..313720d79e 100644 --- a/Source/Core/VideoBackends/D3D/Render.cpp +++ b/Source/Core/VideoBackends/D3D/Render.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include #include @@ -86,7 +87,7 @@ static void SetupDeviceObjects() { s_television.Init(); - g_framebuffer_manager = new FramebufferManager; + g_framebuffer_manager = std::make_unique(); HRESULT hr; float colmat[20]= {0.0f}; @@ -169,7 +170,7 @@ static void SetupDeviceObjects() // Kill off all device objects static void TeardownDeviceObjects() { - delete g_framebuffer_manager; + g_framebuffer_manager.reset(); SAFE_RELEASE(access_efb_cbuf); SAFE_RELEASE(clearblendstates[0]); @@ -999,8 +1000,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co D3D::context->OMSetRenderTargets(1, &D3D::GetBackBuffer()->GetRTV(), nullptr); - delete g_framebuffer_manager; - g_framebuffer_manager = new FramebufferManager; + g_framebuffer_manager = std::make_unique(); float clear_col[4] = { 0.f, 0.f, 0.f, 1.f }; D3D::context->ClearRenderTargetView(FramebufferManager::GetEFBColorTexture()->GetRTV(), clear_col); D3D::context->ClearDepthStencilView(FramebufferManager::GetEFBDepthTexture()->GetDSV(), D3D11_CLEAR_DEPTH, 0.f, 0); diff --git a/Source/Core/VideoBackends/OGL/Render.cpp b/Source/Core/VideoBackends/OGL/Render.cpp index 6b852c3823..f0558828fe 100644 --- a/Source/Core/VideoBackends/OGL/Render.cpp +++ b/Source/Core/VideoBackends/OGL/Render.cpp @@ -70,7 +70,7 @@ VideoConfig g_ogl_config; // Declarations and definitions // ---------------------------- -static RasterFont* s_pfont = nullptr; +static std::unique_ptr s_raster_font; // 1 for no MSAA. Use s_MSAASamples > 1 to check for MSAA. static int s_MSAASamples = 1; @@ -669,16 +669,13 @@ Renderer::~Renderer() void Renderer::Shutdown() { - delete g_framebuffer_manager; + g_framebuffer_manager.reset(); g_Config.bRunning = false; UpdateActiveConfig(); - delete s_pfont; - s_pfont = nullptr; - - delete m_post_processor; - m_post_processor = nullptr; + s_raster_font.reset(); + m_post_processor.reset(); OpenGL_DeleteAttributelessVAO(); } @@ -686,12 +683,11 @@ void Renderer::Shutdown() void Renderer::Init() { // Initialize the FramebufferManager - g_framebuffer_manager = new FramebufferManager(s_target_width, s_target_height, + g_framebuffer_manager = std::make_unique(s_target_width, s_target_height, s_MSAASamples); - m_post_processor = new OpenGLPostProcessing(); - - s_pfont = new RasterFont(); + m_post_processor = std::make_unique(); + s_raster_font = std::make_unique(); OpenGL_CreateAttributelessVAO(); } @@ -701,7 +697,7 @@ void Renderer::RenderText(const std::string& text, int left, int top, u32 color) const int nBackbufferWidth = (int)GLInterface->GetBackBufferWidth(); const int nBackbufferHeight = (int)GLInterface->GetBackBufferHeight(); - s_pfont->printMultilineText(text, + s_raster_font->printMultilineText(text, left * 2.0f / (float)nBackbufferWidth - 1, 1 - top * 2.0f / (float)nBackbufferHeight, 0, nBackbufferWidth, nBackbufferHeight, color); @@ -1515,9 +1511,7 @@ void Renderer::SwapImpl(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight, co OSD::AddMessage(StringFromFormat("%d Anti Aliasing samples selected, but only %d supported by your GPU.", s_last_multisamples, g_ogl_config.max_samples), 10000); } - delete g_framebuffer_manager; - g_framebuffer_manager = new FramebufferManager(s_target_width, s_target_height, - s_MSAASamples); + g_framebuffer_manager = std::make_unique(s_target_width, s_target_height, s_MSAASamples); PixelShaderManager::SetEfbScaleChanged(); } diff --git a/Source/Core/VideoCommon/FramebufferManagerBase.cpp b/Source/Core/VideoCommon/FramebufferManagerBase.cpp index c6d5567d57..c5597dddba 100644 --- a/Source/Core/VideoCommon/FramebufferManagerBase.cpp +++ b/Source/Core/VideoCommon/FramebufferManagerBase.cpp @@ -9,7 +9,7 @@ #include "VideoCommon/RenderBase.h" #include "VideoCommon/VideoConfig.h" -FramebufferManagerBase *g_framebuffer_manager; +std::unique_ptr g_framebuffer_manager; std::unique_ptr FramebufferManagerBase::m_realXFBSource; // Only used in Real XFB mode FramebufferManagerBase::VirtualXFBListType FramebufferManagerBase::m_virtualXFBList; // Only used in Virtual XFB mode diff --git a/Source/Core/VideoCommon/FramebufferManagerBase.h b/Source/Core/VideoCommon/FramebufferManagerBase.h index 078652feb5..ab4ef577d9 100644 --- a/Source/Core/VideoCommon/FramebufferManagerBase.h +++ b/Source/Core/VideoCommon/FramebufferManagerBase.h @@ -104,4 +104,4 @@ private: static unsigned int s_last_xfb_height; }; -extern FramebufferManagerBase *g_framebuffer_manager; +extern std::unique_ptr g_framebuffer_manager; diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 40b6dd5bae..cd032506a0 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -41,6 +41,7 @@ #include "VideoCommon/FramebufferManagerBase.h" #include "VideoCommon/MainBase.h" #include "VideoCommon/OpcodeDecoding.h" +#include "VideoCommon/PostProcessing.h" #include "VideoCommon/RenderBase.h" #include "VideoCommon/Statistics.h" #include "VideoCommon/TextureCacheBase.h" @@ -69,7 +70,7 @@ int Renderer::s_target_height; int Renderer::s_backbuffer_width; int Renderer::s_backbuffer_height; -PostProcessingShaderImplementation* Renderer::m_post_processor; +std::unique_ptr Renderer::m_post_processor; TargetRectangle Renderer::target_rc; diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index b411b2d14f..c04fe15543 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -130,7 +130,7 @@ public: static PEControl::PixelFormat GetPrevPixelFormat() { return prev_efb_format; } static void StorePixelFormat(PEControl::PixelFormat new_format) { prev_efb_format = new_format; } - PostProcessingShaderImplementation* GetPostProcessor() { return m_post_processor; } + PostProcessingShaderImplementation* GetPostProcessor() { return m_post_processor.get(); } // Max height/width virtual int GetMaxTextureSize() = 0; @@ -173,7 +173,7 @@ protected: FPSCounter m_fps_counter; - static PostProcessingShaderImplementation* m_post_processor; + static std::unique_ptr m_post_processor; private: static PEControl::PixelFormat prev_efb_format;