extract OGL::FramebufferManager::BindLayeredTexture
This commit is contained in:
parent
69cedf4144
commit
56fe938366
|
@ -88,6 +88,17 @@ GLuint FramebufferManager::CreateTexture(GLenum texture_type, GLenum internal_fo
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FramebufferManager::BindLayeredTexture(GLuint texture, const std::vector<GLuint>& framebuffers, GLenum attachment, GLenum texture_type)
|
||||||
|
{
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, framebuffers[0]);
|
||||||
|
FramebufferTexture(GL_FRAMEBUFFER, attachment, texture_type, texture, 0);
|
||||||
|
// Bind all the other layers as separate FBOs for blitting.
|
||||||
|
for (unsigned int i = 1; i < m_EFBLayers; i++) {
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, m_resolvedFramebuffer[i]);
|
||||||
|
glFramebufferTextureLayer(GL_FRAMEBUFFER, attachment, texture, 0, i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int msaaSamples)
|
FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int msaaSamples)
|
||||||
{
|
{
|
||||||
m_xfbFramebuffer = 0;
|
m_xfbFramebuffer = 0;
|
||||||
|
@ -145,23 +156,13 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
||||||
|
|
||||||
// Bind resolved textures to resolved framebuffer.
|
// Bind resolved textures to resolved framebuffer.
|
||||||
glGenFramebuffers(m_EFBLayers, m_resolvedFramebuffer.data());
|
glGenFramebuffers(m_EFBLayers, m_resolvedFramebuffer.data());
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_resolvedFramebuffer[0]);
|
BindLayeredTexture(m_resolvedColorTexture, m_resolvedFramebuffer, GL_COLOR_ATTACHMENT0, resolvedType);
|
||||||
FramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, resolvedType, m_resolvedColorTexture,
|
BindLayeredTexture(m_resolvedDepthTexture, m_resolvedFramebuffer, GL_DEPTH_ATTACHMENT, resolvedType);
|
||||||
0);
|
|
||||||
FramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, resolvedType, m_resolvedDepthTexture,
|
|
||||||
0);
|
|
||||||
|
|
||||||
// Bind all the other layers as separate FBOs for blitting.
|
|
||||||
for (unsigned int i = 1; i < m_EFBLayers; i++)
|
|
||||||
{
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_resolvedFramebuffer[i]);
|
|
||||||
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_resolvedColorTexture, 0, i);
|
|
||||||
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_resolvedDepthTexture, 0, i);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
m_efbColor = CreateTexture(m_textureType, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE);
|
m_efbColor = CreateTexture(m_textureType, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE);
|
||||||
m_efbDepth = CreateTexture(m_textureType, GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT, GL_FLOAT);
|
m_efbDepth = CreateTexture(m_textureType, GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL,
|
||||||
|
GL_FLOAT_32_UNSIGNED_INT_24_8_REV);
|
||||||
m_efbColorSwap = CreateTexture(m_textureType, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE);
|
m_efbColorSwap = CreateTexture(m_textureType, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE);
|
||||||
|
|
||||||
// Create XFB framebuffer; targets will be created elsewhere.
|
// Create XFB framebuffer; targets will be created elsewhere.
|
||||||
|
@ -169,17 +170,8 @@ FramebufferManager::FramebufferManager(int targetWidth, int targetHeight, int ms
|
||||||
|
|
||||||
// Bind target textures to EFB framebuffer.
|
// Bind target textures to EFB framebuffer.
|
||||||
glGenFramebuffers(m_EFBLayers, m_efbFramebuffer.data());
|
glGenFramebuffers(m_EFBLayers, m_efbFramebuffer.data());
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_efbFramebuffer[0]);
|
BindLayeredTexture(m_efbColor, m_efbFramebuffer, GL_COLOR_ATTACHMENT0, m_textureType);
|
||||||
FramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_textureType, m_efbColor, 0);
|
BindLayeredTexture(m_efbDepth, m_efbFramebuffer, GL_DEPTH_ATTACHMENT, m_textureType);
|
||||||
FramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_textureType, m_efbDepth, 0);
|
|
||||||
|
|
||||||
// Bind all the other layers as separate FBOs for blitting.
|
|
||||||
for (unsigned int i = 1; i < m_EFBLayers; i++)
|
|
||||||
{
|
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, m_efbFramebuffer[i]);
|
|
||||||
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, m_efbColor, 0, i);
|
|
||||||
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, m_efbDepth, 0, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// EFB framebuffer is currently bound, make sure to clear it before use.
|
// EFB framebuffer is currently bound, make sure to clear it before use.
|
||||||
glViewport(0, 0, m_targetWidth, m_targetHeight);
|
glViewport(0, 0, m_targetWidth, m_targetHeight);
|
||||||
|
|
|
@ -104,6 +104,7 @@ public:
|
||||||
private:
|
private:
|
||||||
GLuint CreateTexture(GLenum texture_type, GLenum internal_format, GLenum pixel_format,
|
GLuint CreateTexture(GLenum texture_type, GLenum internal_format, GLenum pixel_format,
|
||||||
GLenum data_type);
|
GLenum data_type);
|
||||||
|
void BindLayeredTexture(GLuint texture, const std::vector<GLuint>& framebuffers, GLenum attachment, GLenum texture_type);
|
||||||
std::unique_ptr<XFBSourceBase> CreateXFBSource(unsigned int target_width,
|
std::unique_ptr<XFBSourceBase> CreateXFBSource(unsigned int target_width,
|
||||||
unsigned int target_height,
|
unsigned int target_height,
|
||||||
unsigned int layers) override;
|
unsigned int layers) override;
|
||||||
|
|
Loading…
Reference in New Issue