Merge pull request #3380 from lioncash/fb
FramebufferManager: Get rid of raw new and delete
This commit is contained in:
commit
14e976a5f1
|
@ -3,6 +3,7 @@
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/Common.h"
|
#include "Common/Common.h"
|
||||||
#include "Common/CommonFuncs.h"
|
#include "Common/CommonFuncs.h"
|
||||||
|
@ -26,14 +27,14 @@ int FramebufferManager::m_targetHeight;
|
||||||
int FramebufferManager::m_msaaSamples;
|
int FramebufferManager::m_msaaSamples;
|
||||||
|
|
||||||
GLenum FramebufferManager::m_textureType;
|
GLenum FramebufferManager::m_textureType;
|
||||||
GLuint* FramebufferManager::m_efbFramebuffer;
|
std::vector<GLuint> FramebufferManager::m_efbFramebuffer;
|
||||||
GLuint FramebufferManager::m_xfbFramebuffer;
|
GLuint FramebufferManager::m_xfbFramebuffer;
|
||||||
GLuint FramebufferManager::m_efbColor;
|
GLuint FramebufferManager::m_efbColor;
|
||||||
GLuint FramebufferManager::m_efbDepth;
|
GLuint FramebufferManager::m_efbDepth;
|
||||||
GLuint FramebufferManager::m_efbColorSwap; // for hot swap when reinterpreting EFB pixel formats
|
GLuint FramebufferManager::m_efbColorSwap; // for hot swap when reinterpreting EFB pixel formats
|
||||||
|
|
||||||
// Only used in MSAA mode.
|
// Only used in MSAA mode.
|
||||||
GLuint* FramebufferManager::m_resolvedFramebuffer;
|
std::vector<GLuint> FramebufferManager::m_resolvedFramebuffer;
|
||||||
GLuint FramebufferManager::m_resolvedColorTexture;
|
GLuint FramebufferManager::m_resolvedColorTexture;
|
||||||
GLuint FramebufferManager::m_resolvedDepthTexture;
|
GLuint FramebufferManager::m_resolvedDepthTexture;
|
||||||
|
|
||||||
|
@ -79,8 +80,8 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
||||||
m_efbColorSwap = glObj[2];
|
m_efbColorSwap = glObj[2];
|
||||||
|
|
||||||
m_EFBLayers = (g_ActiveConfig.iStereoMode > 0) ? 2 : 1;
|
m_EFBLayers = (g_ActiveConfig.iStereoMode > 0) ? 2 : 1;
|
||||||
m_efbFramebuffer = new GLuint[m_EFBLayers]();
|
m_efbFramebuffer.resize(m_EFBLayers);
|
||||||
m_resolvedFramebuffer = new GLuint[m_EFBLayers]();
|
m_resolvedFramebuffer.resize(m_EFBLayers);
|
||||||
|
|
||||||
// OpenGL MSAA textures are a different kind of texture type and must be allocated
|
// OpenGL MSAA textures are a different kind of texture type and must be allocated
|
||||||
// with a different function, so we create them separately.
|
// with a different function, so we create them separately.
|
||||||
|
@ -183,7 +184,7 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
||||||
glTexImage3D(resolvedType, 0, GL_DEPTH_COMPONENT32F, m_targetWidth, m_targetHeight, m_EFBLayers, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);
|
glTexImage3D(resolvedType, 0, GL_DEPTH_COMPONENT32F, m_targetWidth, m_targetHeight, m_EFBLayers, 0, GL_DEPTH_COMPONENT, GL_FLOAT, nullptr);
|
||||||
|
|
||||||
// Bind resolved textures to resolved framebuffer.
|
// Bind resolved textures to resolved framebuffer.
|
||||||
glGenFramebuffers(m_EFBLayers, m_resolvedFramebuffer);
|
glGenFramebuffers(m_EFBLayers, m_resolvedFramebuffer.data());
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_resolvedFramebuffer[0]);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_resolvedFramebuffer[0]);
|
||||||
FramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, resolvedType, m_resolvedColorTexture, 0);
|
FramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, resolvedType, m_resolvedColorTexture, 0);
|
||||||
FramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, resolvedType, m_resolvedDepthTexture, 0);
|
FramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, resolvedType, m_resolvedDepthTexture, 0);
|
||||||
|
@ -201,7 +202,7 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
||||||
glGenFramebuffers(1, &m_xfbFramebuffer);
|
glGenFramebuffers(1, &m_xfbFramebuffer);
|
||||||
|
|
||||||
// Bind target textures to EFB framebuffer.
|
// Bind target textures to EFB framebuffer.
|
||||||
glGenFramebuffers(m_EFBLayers, m_efbFramebuffer);
|
glGenFramebuffers(m_EFBLayers, m_efbFramebuffer.data());
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_efbFramebuffer[0]);
|
glBindFramebuffer(GL_FRAMEBUFFER, m_efbFramebuffer[0]);
|
||||||
FramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_textureType, m_efbColor, 0);
|
FramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_textureType, m_efbColor, 0);
|
||||||
FramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_textureType, m_efbDepth, 0);
|
FramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_textureType, m_efbDepth, 0);
|
||||||
|
@ -414,12 +415,12 @@ FramebufferManager::~FramebufferManager()
|
||||||
|
|
||||||
// Note: OpenGL deletion functions silently ignore parameters of "0".
|
// Note: OpenGL deletion functions silently ignore parameters of "0".
|
||||||
|
|
||||||
glDeleteFramebuffers(m_EFBLayers, m_efbFramebuffer);
|
glDeleteFramebuffers(m_EFBLayers, m_efbFramebuffer.data());
|
||||||
glDeleteFramebuffers(m_EFBLayers, m_resolvedFramebuffer);
|
glDeleteFramebuffers(m_EFBLayers, m_resolvedFramebuffer.data());
|
||||||
delete [] m_efbFramebuffer;
|
|
||||||
delete [] m_resolvedFramebuffer;
|
// Required, as these are static class members
|
||||||
m_efbFramebuffer = nullptr;
|
m_efbFramebuffer.clear();
|
||||||
m_resolvedFramebuffer = nullptr;
|
m_resolvedFramebuffer.clear();
|
||||||
|
|
||||||
glDeleteFramebuffers(1, &m_xfbFramebuffer);
|
glDeleteFramebuffers(1, &m_xfbFramebuffer);
|
||||||
m_xfbFramebuffer = 0;
|
m_xfbFramebuffer = 0;
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
#include "Common/GL/GLUtil.h"
|
#include "Common/GL/GLUtil.h"
|
||||||
#include "VideoBackends/OGL/ProgramShaderCache.h"
|
#include "VideoBackends/OGL/ProgramShaderCache.h"
|
||||||
|
@ -69,7 +70,7 @@ public:
|
||||||
static GLuint GetEFBColorTexture(const EFBRectangle& sourceRc);
|
static GLuint GetEFBColorTexture(const EFBRectangle& sourceRc);
|
||||||
static GLuint GetEFBDepthTexture(const EFBRectangle& sourceRc);
|
static GLuint GetEFBDepthTexture(const EFBRectangle& sourceRc);
|
||||||
|
|
||||||
static GLuint GetEFBFramebuffer(unsigned int layer = 0) { return (layer < m_EFBLayers) ? m_efbFramebuffer[layer] : m_efbFramebuffer[m_EFBLayers - 1]; }
|
static GLuint GetEFBFramebuffer(unsigned int layer = 0) { return (layer < m_EFBLayers) ? m_efbFramebuffer[layer] : m_efbFramebuffer.back(); }
|
||||||
static GLuint GetXFBFramebuffer() { return m_xfbFramebuffer; }
|
static GLuint GetXFBFramebuffer() { return m_xfbFramebuffer; }
|
||||||
|
|
||||||
// Resolved framebuffer is only used in MSAA mode.
|
// Resolved framebuffer is only used in MSAA mode.
|
||||||
|
@ -105,14 +106,14 @@ private:
|
||||||
static int m_msaaSamples;
|
static int m_msaaSamples;
|
||||||
|
|
||||||
static GLenum m_textureType;
|
static GLenum m_textureType;
|
||||||
static GLuint* m_efbFramebuffer;
|
static std::vector<GLuint> m_efbFramebuffer;
|
||||||
static GLuint m_xfbFramebuffer;
|
static GLuint m_xfbFramebuffer;
|
||||||
static GLuint m_efbColor;
|
static GLuint m_efbColor;
|
||||||
static GLuint m_efbDepth;
|
static GLuint m_efbDepth;
|
||||||
static GLuint m_efbColorSwap;// will be hot swapped with m_efbColor when reinterpreting EFB pixel formats
|
static GLuint m_efbColorSwap;// will be hot swapped with m_efbColor when reinterpreting EFB pixel formats
|
||||||
|
|
||||||
// Only used in MSAA mode, TODO: try to avoid them
|
// Only used in MSAA mode, TODO: try to avoid them
|
||||||
static GLuint* m_resolvedFramebuffer;
|
static std::vector<GLuint> m_resolvedFramebuffer;
|
||||||
static GLuint m_resolvedColorTexture;
|
static GLuint m_resolvedColorTexture;
|
||||||
static GLuint m_resolvedDepthTexture;
|
static GLuint m_resolvedDepthTexture;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue