[Bf-blender-cvs] [32710741203] master: GL: FrameBuffer: Set GL_FRAMEBUFFER_SRGB if needed

Clément Foucault noreply at git.blender.org
Wed Oct 14 18:54:27 CEST 2020


Commit: 327107412032d075c63427d86e5154a5e37b8d4a
Author: Clément Foucault
Date:   Wed Oct 14 18:15:50 2020 +0200
Branches: master
https://developer.blender.org/rB327107412032d075c63427d86e5154a5e37b8d4a

GL: FrameBuffer: Set GL_FRAMEBUFFER_SRGB if needed

This makes possible to rebind the same GPUFrameBuffer to enable or
disable sRGB encoding transform.

===================================================================

M	source/blender/gpu/opengl/gl_framebuffer.cc
M	source/blender/gpu/opengl/gl_framebuffer.hh

===================================================================

diff --git a/source/blender/gpu/opengl/gl_framebuffer.cc b/source/blender/gpu/opengl/gl_framebuffer.cc
index 4270ba544b5..cd87fc88144 100644
--- a/source/blender/gpu/opengl/gl_framebuffer.cc
+++ b/source/blender/gpu/opengl/gl_framebuffer.cc
@@ -286,20 +286,22 @@ void GLFrameBuffer::bind(bool enabled_srgb)
     this->scissor_reset();
   }
 
-  if (context_->active_fb != this) {
-    context_->active_fb = this;
-    state_manager_->active_fb = this;
-    dirty_state_ = true;
-
+  if (context_->active_fb != this || enabled_srgb_ != enabled_srgb) {
+    enabled_srgb_ = enabled_srgb;
     if (enabled_srgb) {
       glEnable(GL_FRAMEBUFFER_SRGB);
     }
     else {
       glDisable(GL_FRAMEBUFFER_SRGB);
     }
-
     GPU_shader_set_framebuffer_srgb_target(enabled_srgb && srgb_);
   }
+
+  if (context_->active_fb != this) {
+    context_->active_fb = this;
+    state_manager_->active_fb = this;
+    dirty_state_ = true;
+  }
 }
 
 /** \} */
diff --git a/source/blender/gpu/opengl/gl_framebuffer.hh b/source/blender/gpu/opengl/gl_framebuffer.hh
index 755f3f97567..33c1cd0befa 100644
--- a/source/blender/gpu/opengl/gl_framebuffer.hh
+++ b/source/blender/gpu/opengl/gl_framebuffer.hh
@@ -55,6 +55,8 @@ class GLFrameBuffer : public FrameBuffer {
   bool immutable_;
   /** True is the framebuffer has it's first color target using the GPU_SRGB8_A8 format. */
   bool srgb_;
+  /** True is the framebuffer has been bound using the GL_FRAMEBUFFER_SRGB feature. */
+  bool enabled_srgb_ = false;
 
  public:
   /**



More information about the Bf-blender-cvs mailing list