GL: FrameBuffer: Set GL_FRAMEBUFFER_SRGB if needed

This makes possible to rebind the same GPUFrameBuffer to enable or
disable sRGB encoding transform.
This commit is contained in:
Clément Foucault 2020-10-14 18:15:50 +02:00
parent 4fa4245464
commit 3271074120
Notes: blender-bot 2023-02-14 06:49:54 +01:00
Referenced by issue #82001, Window gets "overbright" when pressing Ctrl S on Maximized Area.
Referenced by issue #81969, UI turns whiteish when playing video sequence based on a scene and moving in the image editor after saving
2 changed files with 10 additions and 6 deletions

View File

@ -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;
}
}
/** \} */

View File

@ -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:
/**