[Bf-blender-cvs] [73f612fa3bd] draw-colormanagement: GPU: Add sRGB framebuffer support

Clément Foucault noreply at git.blender.org
Wed Jan 22 19:39:49 CET 2020


Commit: 73f612fa3bd4f6becd6ceecea595360faf80750a
Author: Clément Foucault
Date:   Wed Jan 22 17:47:13 2020 +0100
Branches: draw-colormanagement
https://developer.blender.org/rB73f612fa3bd4f6becd6ceecea595360faf80750a

GPU: Add sRGB framebuffer support

Only enable GL_FRAMEBUFFER_SRGB on framebuffer objects as the main
framebuffer is likely to be srgb, and as of now we don't use linear
color for area texture.

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

M	source/blender/gpu/GPU_texture.h
M	source/blender/gpu/intern/gpu_framebuffer.c
M	source/blender/gpu/intern/gpu_texture.c

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

diff --git a/source/blender/gpu/GPU_texture.h b/source/blender/gpu/GPU_texture.h
index 19c7386ad6d..b728a27d55d 100644
--- a/source/blender/gpu/GPU_texture.h
+++ b/source/blender/gpu/GPU_texture.h
@@ -98,6 +98,7 @@ typedef enum eGPUTextureFormat {
   GPU_R11F_G11F_B10F,
   GPU_DEPTH32F_STENCIL8,
   GPU_DEPTH24_STENCIL8,
+  GPU_SRGB8_A8,
 
   /* Texture only format */
   GPU_RGB16F,
@@ -123,7 +124,6 @@ typedef enum eGPUTextureFormat {
 
 /* Special formats texture only */
 #if 0
-  GPU_SRGB8_A8,
   GPU_SRGB8,
   GPU_RGB9_E5,
   GPU_COMPRESSED_RG_RGTC2,
diff --git a/source/blender/gpu/intern/gpu_framebuffer.c b/source/blender/gpu/intern/gpu_framebuffer.c
index a531c22365c..b0fbb0eae49 100644
--- a/source/blender/gpu/intern/gpu_framebuffer.c
+++ b/source/blender/gpu/intern/gpu_framebuffer.c
@@ -513,6 +513,7 @@ void GPU_framebuffer_bind(GPUFrameBuffer *fb)
 
   if (GPU_framebuffer_active_get() != fb) {
     glBindFramebuffer(GL_FRAMEBUFFER, fb->object);
+    glEnable(GL_FRAMEBUFFER_SRGB);
   }
 
   gpu_framebuffer_current_set(fb);
@@ -547,6 +548,7 @@ void GPU_framebuffer_restore(void)
   if (GPU_framebuffer_active_get() != NULL) {
     glBindFramebuffer(GL_FRAMEBUFFER, GPU_framebuffer_default());
     gpu_framebuffer_current_set(NULL);
+    glDisable(GL_FRAMEBUFFER_SRGB);
   }
 }
 
diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c
index 84328b8dfd4..49f0cbedb54 100644
--- a/source/blender/gpu/intern/gpu_texture.c
+++ b/source/blender/gpu/intern/gpu_texture.c
@@ -183,6 +183,7 @@ static int gpu_get_component_count(eGPUTextureFormat format)
     case GPU_RGBA16F:
     case GPU_RGBA16:
     case GPU_RGBA32F:
+    case GPU_SRGB8_A8:
       return 4;
     case GPU_RGB16F:
     case GPU_R11F_G11F_B10F:
@@ -221,7 +222,7 @@ static void gpu_validate_data_format(eGPUTextureFormat tex_format, eGPUDataForma
       }
     }
     /* Byte formats */
-    else if (ELEM(tex_format, GPU_R8, GPU_RG8, GPU_RGBA8, GPU_RGBA8UI)) {
+    else if (ELEM(tex_format, GPU_R8, GPU_RG8, GPU_RGBA8, GPU_RGBA8UI, GPU_SRGB8_A8)) {
       BLI_assert(ELEM(data_format, GPU_DATA_UNSIGNED_BYTE, GPU_DATA_FLOAT));
     }
     /* Special case */
@@ -349,6 +350,7 @@ static uint gpu_get_bytesize(eGPUTextureFormat data_type)
     case GPU_DEPTH_COMPONENT32F:
     case GPU_RGBA8UI:
     case GPU_RGBA8:
+    case GPU_SRGB8_A8:
     case GPU_R11F_G11F_B10F:
     case GPU_R32F:
     case GPU_R32UI:
@@ -398,6 +400,8 @@ static GLenum gpu_get_gl_internalformat(eGPUTextureFormat format)
       return GL_RGBA8;
     case GPU_RGBA8UI:
       return GL_RGBA8UI;
+    case GPU_SRGB8_A8:
+      return GL_SRGB8_ALPHA8;
     case GPU_R32F:
       return GL_R32F;
     case GPU_R32UI:



More information about the Bf-blender-cvs mailing list