i915: Add support for GL_EXT_texture_sRGB and GL_EXT_texture_sRGB_decode.
authorEric Anholt <eric@anholt.net>
Thu, 18 Apr 2013 02:10:29 +0000 (19:10 -0700)
committerEric Anholt <eric@anholt.net>
Mon, 29 Apr 2013 18:41:33 +0000 (11:41 -0700)
This brings the driver up to GL 2.1.

src/mesa/drivers/dri/i915/i915_context.c
src/mesa/drivers/dri/i915/i915_texstate.c
src/mesa/drivers/dri/intel/intel_extensions.c

index 46fc96642218a87a1bd304ad5a69a14ec3314d56..65b50ea6700d2220a370065e63a7c3420a1ec258 100644 (file)
@@ -104,6 +104,8 @@ intel_init_texture_formats(struct gl_context *ctx)
    if (intel_screen->deviceID != PCI_CHIP_I830_M &&
        intel_screen->deviceID != PCI_CHIP_845_G)
       ctx->TextureFormatSupported[MESA_FORMAT_XRGB8888] = true;
+   if (intel->gen == 3)
+      ctx->TextureFormatSupported[MESA_FORMAT_SARGB8] = true;
    ctx->TextureFormatSupported[MESA_FORMAT_ARGB4444] = true;
    ctx->TextureFormatSupported[MESA_FORMAT_ARGB1555] = true;
    ctx->TextureFormatSupported[MESA_FORMAT_RGB565] = true;
index 2f3286920d5182fb4af931de1eae7c2506248012..43c802b2c088e8d7ab9d7598a656cf7596247097 100644 (file)
@@ -56,6 +56,7 @@ translate_texture_format(gl_format mesa_format, GLenum DepthMode)
       return MAPSURF_16BIT | MT_16BIT_ARGB1555;
    case MESA_FORMAT_ARGB4444:
       return MAPSURF_16BIT | MT_16BIT_ARGB4444;
+   case MESA_FORMAT_SARGB8:
    case MESA_FORMAT_ARGB8888:
       return MAPSURF_32BIT | MT_32BIT_ARGB8888;
    case MESA_FORMAT_XRGB8888:
@@ -78,10 +79,14 @@ translate_texture_format(gl_format mesa_format, GLenum DepthMode)
           return (MAPSURF_16BIT | MT_16BIT_L16);
    case MESA_FORMAT_RGBA_DXT1:
    case MESA_FORMAT_RGB_DXT1:
+   case MESA_FORMAT_SRGB_DXT1:
+   case MESA_FORMAT_SRGBA_DXT1:
       return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT1);
    case MESA_FORMAT_RGBA_DXT3:
+   case MESA_FORMAT_SRGBA_DXT3:
       return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT2_3);
    case MESA_FORMAT_RGBA_DXT5:
+   case MESA_FORMAT_SRGBA_DXT5:
       return (MAPSURF_COMPRESSED | MT_COMPRESS_DXT4_5);
    case MESA_FORMAT_S8_Z24:
    case MESA_FORMAT_X8_Z24:
@@ -354,6 +359,12 @@ i915_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
 
    }
 
+   if (sampler->sRGBDecode == GL_DECODE_EXT &&
+       (_mesa_get_srgb_format_linear(firstImage->TexFormat) !=
+        firstImage->TexFormat)) {
+      state[I915_TEXREG_SS2] |= SS2_REVERSE_GAMMA_ENABLE;
+   }
+
    /* convert border color from float to ubyte */
    CLAMPED_FLOAT_TO_UBYTE(border[0], sampler->BorderColor.f[0]);
    CLAMPED_FLOAT_TO_UBYTE(border[1], sampler->BorderColor.f[1]);
index 46722e1cd7108752ba01d483cb2e4a4f4b1b8859..18f19b8eefea0f2d4f54f4cf12cc66a80137afa0 100755 (executable)
@@ -152,8 +152,6 @@ intelInitExtensions(struct gl_context *ctx)
       ctx->Extensions.EXT_texture_array = true;
       ctx->Extensions.EXT_texture_integer = true;
       ctx->Extensions.EXT_texture_snorm = true;
-      ctx->Extensions.EXT_texture_sRGB = true;
-      ctx->Extensions.EXT_texture_sRGB_decode = true;
       ctx->Extensions.EXT_texture_swizzle = true;
       ctx->Extensions.EXT_vertex_array_bgra = true;
       ctx->Extensions.ATI_envmap_bumpmap = true;
@@ -169,6 +167,8 @@ intelInitExtensions(struct gl_context *ctx)
       ctx->Extensions.ARB_fragment_program = true;
       ctx->Extensions.ARB_shadow = true;
       ctx->Extensions.ARB_texture_non_power_of_two = true;
+      ctx->Extensions.EXT_texture_sRGB = true;
+      ctx->Extensions.EXT_texture_sRGB_decode = true;
       ctx->Extensions.EXT_shadow_funcs = true;
       ctx->Extensions.EXT_stencil_two_side = true;
       ctx->Extensions.ATI_separate_stencil = true;