EXT_texture_sRGB support on i965
authorZou Nan hai <nanhai.zou@intel.com>
Thu, 2 Aug 2007 06:26:12 +0000 (14:26 +0800)
committerZou Nan hai <nanhai.zou@intel.com>
Thu, 2 Aug 2007 06:26:12 +0000 (14:26 +0800)
src/mesa/drivers/dri/i965/brw_tex.c
src/mesa/drivers/dri/i965/brw_wm_surface_state.c
src/mesa/drivers/dri/i965/intel_context.c
src/mesa/main/texcompress_s3tc.c
src/mesa/main/texformat.h

index 9d4b986..f8d0c3f 100644 (file)
@@ -168,6 +168,25 @@ brwChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
    case GL_DEPTH_COMPONENT32:
       return &_mesa_texformat_z16;
 
+   case GL_SRGB_EXT:
+   case GL_SRGB8_EXT:
+   case GL_SRGB_ALPHA_EXT:
+   case GL_SRGB8_ALPHA8_EXT:
+   case GL_SLUMINANCE_EXT:
+   case GL_SLUMINANCE8_EXT:
+   case GL_SLUMINANCE_ALPHA_EXT:
+   case GL_SLUMINANCE8_ALPHA8_EXT:
+   case GL_COMPRESSED_SRGB_EXT:
+   case GL_COMPRESSED_SRGB_ALPHA_EXT:
+   case GL_COMPRESSED_SLUMINANCE_EXT:
+   case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
+       return &_mesa_texformat_srgb_dxt1;
+   case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
+   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
+   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
+   case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
+     return &_mesa_texformat_srgb_dxt1;
+
    default:
       fprintf(stderr, "unexpected texture format %s in %s\n", 
              _mesa_lookup_enum_by_nr(internalFormat),
index d546231..acf5771 100644 (file)
@@ -120,6 +120,11 @@ static GLuint translate_tex_format( GLuint mesa_format )
    case MESA_FORMAT_RGB_DXT1:
       return BRW_SURFACEFORMAT_DXT1_RGB;
 
+   case MESA_FORMAT_SRGBA8:
+      return BRW_SURFACEFORMAT_R8G8B8A8_UNORM_SRGB;
+   case MESA_FORMAT_SRGB_DXT1:
+      return BRW_SURFACEFORMAT_BC1_UNORM_SRGB;
+
    default:
       assert(0);
       return 0;
index a8204ee..eafe809 100644 (file)
@@ -182,6 +182,7 @@ const struct dri_extension card_extensions[] =
     { "GL_EXT_texture_env_dot3",           NULL },
     { "GL_EXT_texture_filter_anisotropic", NULL },
     { "GL_EXT_texture_lod_bias",           NULL },
+    { "GL_EXT_texture_sRGB",               NULL },
     { "GL_3DFX_texture_compression_FXT1",  NULL },
     { "GL_APPLE_client_storage",           NULL },
     { "GL_MESA_pack_invert",               NULL },
index c48063d..4f329cd 100644 (file)
@@ -577,6 +577,32 @@ const struct gl_texture_format _mesa_texformat_rgb_dxt1 = {
    NULL                                        /* StoreTexel */
 };
 
+#if FEATURE_EXT_texture_sRGB
+const struct gl_texture_format _mesa_texformat_srgb_dxt1 = {
+   MESA_FORMAT_SRGB_DXT1,              /* MesaFormat */
+   GL_RGB,                             /* BaseFormat */
+   GL_UNSIGNED_NORMALIZED_ARB,         /* DataType */
+   4, /*approx*/                       /* RedBits */
+   4, /*approx*/                       /* GreenBits */
+   4, /*approx*/                       /* BlueBits */
+   0,                                  /* AlphaBits */
+   0,                                  /* LuminanceBits */
+   0,                                  /* IntensityBits */
+   0,                                  /* IndexBits */
+   0,                                  /* DepthBits */
+   0,                                  /* StencilBits */
+   0,                                  /* TexelBytes */
+   texstore_rgb_dxt1,                  /* StoreTexImageFunc */
+   NULL, /*impossible*/                /* FetchTexel1D */
+   fetch_texel_2d_rgb_dxt1,            /* FetchTexel2D */
+   NULL, /*impossible*/                /* FetchTexel3D */
+   NULL, /*impossible*/                /* FetchTexel1Df */
+   fetch_texel_2d_f_rgb_dxt1,          /* FetchTexel2Df */
+   NULL, /*impossible*/                /* FetchTexel3Df */
+   NULL                                        /* StoreTexel */
+};
+#endif
+
 const struct gl_texture_format _mesa_texformat_rgba_dxt1 = {
    MESA_FORMAT_RGBA_DXT1,              /* MesaFormat */
    GL_RGBA,                            /* BaseFormat */
index 55851db..82023b9 100644 (file)
@@ -97,6 +97,7 @@ enum _format {
    MESA_FORMAT_SRGBA8,
    MESA_FORMAT_SL8,
    MESA_FORMAT_SLA8,
+   MESA_FORMAT_SRGB_DXT1,
    /*@}*/
 #endif
 
@@ -168,6 +169,7 @@ extern const struct gl_texture_format _mesa_texformat_srgb8;
 extern const struct gl_texture_format _mesa_texformat_srgba8;
 extern const struct gl_texture_format _mesa_texformat_sl8;
 extern const struct gl_texture_format _mesa_texformat_sla8;
+extern const struct gl_texture_format _mesa_texformat_srgb_dxt1;
 /*@}*/
 #endif