Render: Get rid of explicit new and delete

This commit is contained in:
Lioncash 2015-12-22 18:47:20 -05:00
parent 14e976a5f1
commit da0e647346
6 changed files with 19 additions and 24 deletions

View File

@ -4,6 +4,7 @@
#include <cinttypes> #include <cinttypes>
#include <cmath> #include <cmath>
#include <memory>
#include <string> #include <string>
#include <strsafe.h> #include <strsafe.h>
#include <unordered_map> #include <unordered_map>
@ -86,7 +87,7 @@ static void SetupDeviceObjects()
{ {
s_television.Init(); s_television.Init();
g_framebuffer_manager = new FramebufferManager; g_framebuffer_manager = std::make_unique<FramebufferManager>();
HRESULT hr; HRESULT hr;
float colmat[20]= {0.0f}; float colmat[20]= {0.0f};
@ -169,7 +170,7 @@ static void SetupDeviceObjects()
// Kill off all device objects // Kill off all device objects
static void TeardownDeviceObjects() static void TeardownDeviceObjects()
{ {
delete g_framebuffer_manager; g_framebuffer_manager.reset();
SAFE_RELEASE(access_efb_cbuf); SAFE_RELEASE(access_efb_cbuf);
SAFE_RELEASE(clearblendstates[0]); 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); D3D::context->OMSetRenderTargets(1, &D3D::GetBackBuffer()->GetRTV(), nullptr);
delete g_framebuffer_manager; g_framebuffer_manager = std::make_unique<FramebufferManager>();
g_framebuffer_manager = new FramebufferManager;
float clear_col[4] = { 0.f, 0.f, 0.f, 1.f }; float clear_col[4] = { 0.f, 0.f, 0.f, 1.f };
D3D::context->ClearRenderTargetView(FramebufferManager::GetEFBColorTexture()->GetRTV(), clear_col); D3D::context->ClearRenderTargetView(FramebufferManager::GetEFBColorTexture()->GetRTV(), clear_col);
D3D::context->ClearDepthStencilView(FramebufferManager::GetEFBDepthTexture()->GetDSV(), D3D11_CLEAR_DEPTH, 0.f, 0); D3D::context->ClearDepthStencilView(FramebufferManager::GetEFBDepthTexture()->GetDSV(), D3D11_CLEAR_DEPTH, 0.f, 0);

View File

@ -70,7 +70,7 @@ VideoConfig g_ogl_config;
// Declarations and definitions // Declarations and definitions
// ---------------------------- // ----------------------------
static RasterFont* s_pfont = nullptr; static std::unique_ptr<RasterFont> s_raster_font;
// 1 for no MSAA. Use s_MSAASamples > 1 to check for MSAA. // 1 for no MSAA. Use s_MSAASamples > 1 to check for MSAA.
static int s_MSAASamples = 1; static int s_MSAASamples = 1;
@ -669,16 +669,13 @@ Renderer::~Renderer()
void Renderer::Shutdown() void Renderer::Shutdown()
{ {
delete g_framebuffer_manager; g_framebuffer_manager.reset();
g_Config.bRunning = false; g_Config.bRunning = false;
UpdateActiveConfig(); UpdateActiveConfig();
delete s_pfont; s_raster_font.reset();
s_pfont = nullptr; m_post_processor.reset();
delete m_post_processor;
m_post_processor = nullptr;
OpenGL_DeleteAttributelessVAO(); OpenGL_DeleteAttributelessVAO();
} }
@ -686,12 +683,11 @@ void Renderer::Shutdown()
void Renderer::Init() void Renderer::Init()
{ {
// Initialize the FramebufferManager // Initialize the FramebufferManager
g_framebuffer_manager = new FramebufferManager(s_target_width, s_target_height, g_framebuffer_manager = std::make_unique<FramebufferManager>(s_target_width, s_target_height,
s_MSAASamples); s_MSAASamples);
m_post_processor = new OpenGLPostProcessing(); m_post_processor = std::make_unique<OpenGLPostProcessing>();
s_raster_font = std::make_unique<RasterFont>();
s_pfont = new RasterFont();
OpenGL_CreateAttributelessVAO(); 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 nBackbufferWidth = (int)GLInterface->GetBackBufferWidth();
const int nBackbufferHeight = (int)GLInterface->GetBackBufferHeight(); const int nBackbufferHeight = (int)GLInterface->GetBackBufferHeight();
s_pfont->printMultilineText(text, s_raster_font->printMultilineText(text,
left * 2.0f / (float)nBackbufferWidth - 1, left * 2.0f / (float)nBackbufferWidth - 1,
1 - top * 2.0f / (float)nBackbufferHeight, 1 - top * 2.0f / (float)nBackbufferHeight,
0, nBackbufferWidth, nBackbufferHeight, color); 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); 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 = std::make_unique<FramebufferManager>(s_target_width, s_target_height, s_MSAASamples);
g_framebuffer_manager = new FramebufferManager(s_target_width, s_target_height,
s_MSAASamples);
PixelShaderManager::SetEfbScaleChanged(); PixelShaderManager::SetEfbScaleChanged();
} }

View File

@ -9,7 +9,7 @@
#include "VideoCommon/RenderBase.h" #include "VideoCommon/RenderBase.h"
#include "VideoCommon/VideoConfig.h" #include "VideoCommon/VideoConfig.h"
FramebufferManagerBase *g_framebuffer_manager; std::unique_ptr<FramebufferManagerBase> g_framebuffer_manager;
std::unique_ptr<XFBSourceBase> FramebufferManagerBase::m_realXFBSource; // Only used in Real XFB mode std::unique_ptr<XFBSourceBase> FramebufferManagerBase::m_realXFBSource; // Only used in Real XFB mode
FramebufferManagerBase::VirtualXFBListType FramebufferManagerBase::m_virtualXFBList; // Only used in Virtual XFB mode FramebufferManagerBase::VirtualXFBListType FramebufferManagerBase::m_virtualXFBList; // Only used in Virtual XFB mode

View File

@ -104,4 +104,4 @@ private:
static unsigned int s_last_xfb_height; static unsigned int s_last_xfb_height;
}; };
extern FramebufferManagerBase *g_framebuffer_manager; extern std::unique_ptr<FramebufferManagerBase> g_framebuffer_manager;

View File

@ -41,6 +41,7 @@
#include "VideoCommon/FramebufferManagerBase.h" #include "VideoCommon/FramebufferManagerBase.h"
#include "VideoCommon/MainBase.h" #include "VideoCommon/MainBase.h"
#include "VideoCommon/OpcodeDecoding.h" #include "VideoCommon/OpcodeDecoding.h"
#include "VideoCommon/PostProcessing.h"
#include "VideoCommon/RenderBase.h" #include "VideoCommon/RenderBase.h"
#include "VideoCommon/Statistics.h" #include "VideoCommon/Statistics.h"
#include "VideoCommon/TextureCacheBase.h" #include "VideoCommon/TextureCacheBase.h"
@ -69,7 +70,7 @@ int Renderer::s_target_height;
int Renderer::s_backbuffer_width; int Renderer::s_backbuffer_width;
int Renderer::s_backbuffer_height; int Renderer::s_backbuffer_height;
PostProcessingShaderImplementation* Renderer::m_post_processor; std::unique_ptr<PostProcessingShaderImplementation> Renderer::m_post_processor;
TargetRectangle Renderer::target_rc; TargetRectangle Renderer::target_rc;

View File

@ -130,7 +130,7 @@ public:
static PEControl::PixelFormat GetPrevPixelFormat() { return prev_efb_format; } static PEControl::PixelFormat GetPrevPixelFormat() { return prev_efb_format; }
static void StorePixelFormat(PEControl::PixelFormat new_format) { prev_efb_format = new_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 // Max height/width
virtual int GetMaxTextureSize() = 0; virtual int GetMaxTextureSize() = 0;
@ -173,7 +173,7 @@ protected:
FPSCounter m_fps_counter; FPSCounter m_fps_counter;
static PostProcessingShaderImplementation* m_post_processor; static std::unique_ptr<PostProcessingShaderImplementation> m_post_processor;
private: private:
static PEControl::PixelFormat prev_efb_format; static PEControl::PixelFormat prev_efb_format;