diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-09-17 11:17:38 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-09-17 11:17:47 +0300 |
commit | 1810b1e4c88191e3578518e12f9f3d318e08dc60 (patch) | |
tree | ae868919ad9d4bfd32867ebef1088eb24cefa683 /source/blender/gpu/opengl | |
parent | b37954d03c5de2b131a35fbb4088e8dbf3f4ba2f (diff) |
GL: Framebuffer: Add support for empty framebuffer (no attachments)
This allows to reduce the memory footprint of very large framebuffers if
there is no need for any attachment.
Diffstat (limited to 'source/blender/gpu/opengl')
-rw-r--r-- | source/blender/gpu/opengl/gl_framebuffer.cc | 5 | ||||
-rw-r--r-- | source/blender/gpu/opengl/gl_framebuffer.hh | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/source/blender/gpu/opengl/gl_framebuffer.cc b/source/blender/gpu/opengl/gl_framebuffer.cc index bd9fba4250d..1ab22a16df4 100644 --- a/source/blender/gpu/opengl/gl_framebuffer.cc +++ b/source/blender/gpu/opengl/gl_framebuffer.cc @@ -207,6 +207,11 @@ void GLFrameBuffer::update_attachments() this->size_set(size[0], size[1]); srgb_ = (GPU_texture_format(attach.tex) == GPU_SRGB8_A8); } + else { + /* Empty frame-buffer. */ + glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_WIDTH, width_); + glFramebufferParameteri(GL_FRAMEBUFFER, GL_FRAMEBUFFER_DEFAULT_HEIGHT, height_); + } dirty_attachments_ = false; diff --git a/source/blender/gpu/opengl/gl_framebuffer.hh b/source/blender/gpu/opengl/gl_framebuffer.hh index 8ee04a584bd..edc05322153 100644 --- a/source/blender/gpu/opengl/gl_framebuffer.hh +++ b/source/blender/gpu/opengl/gl_framebuffer.hh @@ -32,7 +32,7 @@ class GLFrameBuffer : public FrameBuffer { /** State Manager of the same contexts. */ GLStateManager *state_manager_ = nullptr; /** Copy of the GL state. Contains ONLY color attachments enums for slot binding. */ - GLenum gl_attachments_[GPU_FB_MAX_COLOR_ATTACHMENT]; + GLenum gl_attachments_[GPU_FB_MAX_COLOR_ATTACHMENT] = {0}; /** Internal frame-buffers are immutable. */ bool immutable_; /** True is the frame-buffer has its first color target using the GPU_SRGB8_A8 format. */ |