mesa/965: add support for GL_EXT_framebuffer_sRGB (v2)
authorDave Airlie <airlied@gmail.com>
Fri, 28 Jan 2011 04:16:00 +0000 (14:16 +1000)
committerDave Airlie <airlied@gmail.com>
Sat, 5 Feb 2011 07:06:30 +0000 (17:06 +1000)
This adds i965 support for GL_EXT_framebuffer_sRGB, it introduces a new
constant to say that the driver can support sRGB enabled FBOs since enabling
the extension doesn't mean the driver can actually support sRGB.

Also adds the suggested state flush in the core code suggested by Brian.

fix the ARB_fbo color encoding.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/drivers/dri/intel/intel_context.c
src/mesa/drivers/dri/intel/intel_extensions.c
src/mesa/main/enable.c
src/mesa/main/fbobject.c
src/mesa/main/framebuffer.c
src/mesa/main/mtypes.h

index a372554555c4c669e04311cd38de1012fa53deae..c931df3c605cf9f1268e4ef9f66c9bec0a004e4a 100644 (file)
@@ -446,7 +446,10 @@ brw_update_renderbuffer_surface(struct brw_context *brw,
    case MESA_FORMAT_SARGB8:
       /* without GL_EXT_framebuffer_sRGB we shouldn't bind sRGB
         surfaces to the blend/update as sRGB */
-      surf.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
+      if (ctx->Color.sRGBEnabled)
+        surf.ss0.surface_format = brw_format_for_mesa_format[irb->Base.Format];
+      else
+        surf.ss0.surface_format = BRW_SURFACEFORMAT_B8G8R8A8_UNORM;
       break;
    default:
       surf.ss0.surface_format = brw_format_for_mesa_format[irb->Base.Format];
index 2a5029964befbf805aa928d993acb2627b103255..432a22a7c3c0c7244a9b20b5b03de7638746687a 100644 (file)
@@ -807,6 +807,7 @@ intelInitContext(struct intel_context *intel,
 
    meta_init_metaops(ctx, &intel->meta);
    if (intel->gen >= 4) {
+      ctx->Const.sRGBCapable = GL_TRUE;
       if (MAX_WIDTH > 8192)
         ctx->Const.MaxRenderbufferSize = 8192;
    } else {
index 747e9dcb7171aeed871601159046408c633a68c4..febc1d4f859d8112256f42ae562c8e9aa755244f 100644 (file)
@@ -175,6 +175,7 @@ static const struct dri_extension brw_extensions[] = {
    { "GL_ARB_texture_non_power_of_two",   NULL },
    { "GL_ARB_texture_rg",                 NULL },
    { "GL_EXT_draw_buffers2",              GL_EXT_draw_buffers2_functions },
+   { "GL_EXT_framebuffer_sRGB",           NULL },
    { "GL_EXT_shadow_funcs",               NULL },
    { "GL_EXT_stencil_two_side",           GL_EXT_stencil_two_side_functions },
    { "GL_EXT_texture_sRGB",              NULL },
index c4c4e1bb29d7acd602a4ad45faa4c926701e97f6..d34c6ff9085884aa7a371c5b6d8bc5ad4dbce099 100644 (file)
@@ -970,9 +970,10 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
 
       /* GL3.0 - GL_framebuffer_sRGB */
       case GL_FRAMEBUFFER_SRGB_EXT:
-        CHECK_EXTENSION(EXT_framebuffer_sRGB, cap);
-        ctx->Color.sRGBEnabled = state;
-        break;
+         CHECK_EXTENSION(EXT_framebuffer_sRGB, cap);
+         FLUSH_VERTICES(ctx, _NEW_BUFFERS);
+         ctx->Color.sRGBEnabled = state;
+         break;
 
       default:
          goto invalid_enum_error;
index 04f02ce37e352006fb6fb107e007e81f039233e0..97cbd3c614d8feb253ddab1da82db9c3e52b8fa5 100644 (file)
@@ -2157,7 +2157,7 @@ _mesa_GetFramebufferAttachmentParameterivEXT(GLenum target, GLenum attachment,
                      "glGetFramebufferAttachmentParameterivEXT(pname)");
       }
       else {
-         if (ctx->Extensions.EXT_framebuffer_sRGB) {
+         if (ctx->Extensions.EXT_framebuffer_sRGB && ctx->Const.sRGBCapable) {
             *params = _mesa_get_format_color_encoding(att->Renderbuffer->Format);
          }
          else {
index 63da71c95b4bd9609173f099e432bed07431da2c..948b3b7b5a23623e4a0e0533df1a0deef5af9b91 100644 (file)
@@ -553,6 +553,8 @@ _mesa_update_framebuffer_visual(struct gl_context *ctx,
                + fb->Visual.greenBits + fb->Visual.blueBits;
             fb->Visual.floatMode = GL_FALSE;
             fb->Visual.samples = rb->NumSamples;
+            if (_mesa_get_format_color_encoding(fmt) == GL_SRGB)
+                fb->Visual.sRGBCapable = ctx->Const.sRGBCapable;
             break;
          }
       }
index 37f39ceef35ea54bec9c4ba95d95484203fd041e..4e7621239123e3ae1c7d5a57bc75e22eb5fd6fcb 100644 (file)
@@ -2710,6 +2710,9 @@ struct gl_constants
 
    /** GL_EXT_gpu_shader4 */
    GLint MinProgramTexelOffset, MaxProgramTexelOffset;
+
+   /* GL_EXT_framebuffer_sRGB */
+   GLboolean sRGBCapable; /* can enable sRGB blend/update on FBOs */
 };