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 9d4b9867d24e7e1509be67ac3dd86e06a526f9ca..f8d0c3fb6fd993d66b12815520227af13201213a 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 d54623175b76bc33c82fdea96fee87c26b750332..acf5771e77931402d3bbe6faee39f40a1f809b9d 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 a8204ee4b81e73e4bb7e8c9c4bb5e0c57ed0fbcd..eafe809d3adec30b516b087ff6ccf26cf3c0a6c6 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 c48063d919244c58f020ff52a326a3c1e7d0e6bb..4f329cdf59be64bf470f03f57adc2603de8ed885 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 55851db70169cb13522b9dff25cb4ecf5a97cab9..82023b946d5ab4ca14ad31ab4136fa535bf88faa 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