i965: add support for EXT_texture_sRGB_decode
authorDave Airlie <airlied@gmail.com>
Thu, 13 Jan 2011 05:54:29 +0000 (15:54 +1000)
committerDave Airlie <airlied@redhat.com>
Sun, 16 Jan 2011 02:54:06 +0000 (12:54 +1000)
We just choose the texture format depending on the srgb decode bit
for the sRGB formats.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/drivers/dri/intel/intel_extensions.c

index 233fe3b731065d2c5cae1b8cb8340c192674f1ed..a372554555c4c669e04311cd38de1012fa53deae 100644 (file)
@@ -120,7 +120,8 @@ brw_render_target_supported(gl_format format)
 
 static GLuint translate_tex_format( gl_format mesa_format,
                                     GLenum internal_format,
-                                   GLenum depth_mode )
+                                   GLenum depth_mode, 
+                                   GLenum srgb_decode )
 {
    switch( mesa_format ) {
 
@@ -146,7 +147,14 @@ static GLuint translate_tex_format( gl_format mesa_format,
          return BRW_SURFACEFORMAT_R24_UNORM_X8_TYPELESS;
       else
          return BRW_SURFACEFORMAT_L24X8_UNORM;
-
+      
+   case MESA_FORMAT_SARGB8:
+   case MESA_FORMAT_SLA8:
+   case MESA_FORMAT_SL8:
+      if (srgb_decode == GL_DECODE_EXT)
+        return brw_format_for_mesa_format[mesa_format];
+      else if (srgb_decode == GL_SKIP_DECODE_EXT)
+        return brw_format_for_mesa_format[_mesa_get_srgb_format_linear(mesa_format)];
    default:
       assert(brw_format_for_mesa_format[mesa_format] != 0);
       return brw_format_for_mesa_format[mesa_format];
@@ -189,7 +197,7 @@ brw_update_texture_surface( struct gl_context *ctx, GLuint unit )
    surf.ss0.surface_type = translate_tex_target(tObj->Target);
    surf.ss0.surface_format = translate_tex_format(firstImage->TexFormat,
                                                  firstImage->InternalFormat,
-                                                 tObj->DepthMode);
+                                                 tObj->DepthMode, tObj->sRGBDecode);
 
    /* This is ok for all textures with channel width 8bit or less:
     */
index fab533f39fc6c61a9e1be6a08c22a6e86be72e13..747e9dcb7171aeed871601159046408c633a68c4 100644 (file)
@@ -178,6 +178,7 @@ static const struct dri_extension brw_extensions[] = {
    { "GL_EXT_shadow_funcs",               NULL },
    { "GL_EXT_stencil_two_side",           GL_EXT_stencil_two_side_functions },
    { "GL_EXT_texture_sRGB",              NULL },
+   { "GL_EXT_texture_sRGB_decode",       NULL },
    { "GL_EXT_texture_swizzle",           NULL },
    { "GL_EXT_vertex_array_bgra",         NULL },
    { "GL_ATI_envmap_bumpmap",             GL_ATI_envmap_bumpmap_functions },