mesa: pass context parameter to gl_renderbuffer::Delete()
[mesa.git] / src / mesa / main / texcompress.c
index 5045aef06cc1db820569e481351ff02b4d6c3aee..957cc6df66124058a3e8820e821686f9c27b2cee 100644 (file)
@@ -275,7 +275,6 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats)
       }
    }
 
-#if FEATURE_ES1
    if (ctx->API == API_OPENGLES) {
       if (formats) {
         formats[n++] = GL_PALETTE4_RGB8_OES;
@@ -293,7 +292,6 @@ _mesa_get_compressed_formats(struct gl_context *ctx, GLint *formats)
         n += 10;
       }
    }
-#endif
 
    return n;
 }
@@ -372,16 +370,13 @@ _mesa_glenum_to_compressed_format(GLenum format)
  * internal format unchanged.
  */
 GLenum
-_mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat)
+_mesa_compressed_format_to_glenum(struct gl_context *ctx, gl_format mesaFormat)
 {
    switch (mesaFormat) {
-#if FEATURE_texture_fxt1
    case MESA_FORMAT_RGB_FXT1:
       return GL_COMPRESSED_RGB_FXT1_3DFX;
    case MESA_FORMAT_RGBA_FXT1:
       return GL_COMPRESSED_RGBA_FXT1_3DFX;
-#endif
-#if FEATURE_texture_s3tc
    case MESA_FORMAT_RGB_DXT1:
       return GL_COMPRESSED_RGB_S3TC_DXT1_EXT;
    case MESA_FORMAT_RGBA_DXT1:
@@ -390,7 +385,6 @@ _mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat)
       return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT;
    case MESA_FORMAT_RGBA_DXT5:
       return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
-#if FEATURE_EXT_texture_sRGB
    case MESA_FORMAT_SRGB_DXT1:
       return GL_COMPRESSED_SRGB_S3TC_DXT1_EXT;
    case MESA_FORMAT_SRGBA_DXT1:
@@ -399,9 +393,6 @@ _mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat)
       return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT;
    case MESA_FORMAT_SRGBA_DXT5:
       return GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT;
-#endif
-#endif
-
    case MESA_FORMAT_RED_RGTC1:
       return GL_COMPRESSED_RED_RGTC1;
    case MESA_FORMAT_SIGNED_RED_RGTC1:
@@ -465,6 +456,8 @@ _mesa_compressed_image_address(GLint col, GLint row, GLint img,
 
 /**
  * Decompress a compressed texture image, returning a GL_RGBA/GL_FLOAT image.
+ * \param srcRowStride  stride in bytes between rows of blocks in the
+ *                      compressed source image.
  */
 void
 _mesa_decompress_image(gl_format format, GLuint width, GLuint height,
@@ -475,25 +468,33 @@ _mesa_decompress_image(gl_format format, GLuint width, GLuint height,
                  GLint i, GLint j, GLint k, GLfloat *texel);
    struct swrast_texture_image texImage;  /* dummy teximage */
    GLuint i, j;
+   GLuint bytes, bw, bh;
+
+   bytes = _mesa_get_format_bytes(format);
+   _mesa_get_format_block_size(format, &bw, &bh);
 
    /* setup dummy texture image info */
    memset(&texImage, 0, sizeof(texImage));
-   texImage.Data = (void *) src;
-   texImage.RowStride = srcRowStride;
+   texImage.Map = (void *) src;
+
+   /* XXX This line is a bit of a hack to adapt to the row stride
+    * convention used by the texture decompression functions.
+    */
+   texImage.RowStride = srcRowStride * bh / bytes;
 
    switch (format) {
    /* DXT formats */
    case MESA_FORMAT_RGB_DXT1:
-      fetch = _mesa_fetch_texel_2d_f_rgb_dxt1;
+      fetch = _mesa_fetch_texel_rgb_dxt1;
       break;
    case MESA_FORMAT_RGBA_DXT1:
-      fetch = _mesa_fetch_texel_2d_f_rgba_dxt1;
+      fetch = _mesa_fetch_texel_rgba_dxt1;
       break;
    case MESA_FORMAT_RGBA_DXT3:
-      fetch = _mesa_fetch_texel_2d_f_rgba_dxt3;
+      fetch = _mesa_fetch_texel_rgba_dxt3;
       break;
    case MESA_FORMAT_RGBA_DXT5:
-      fetch = _mesa_fetch_texel_2d_f_rgba_dxt5;
+      fetch = _mesa_fetch_texel_rgba_dxt5;
       break;
 
    /* FXT1 formats */
@@ -506,30 +507,30 @@ _mesa_decompress_image(gl_format format, GLuint width, GLuint height,
 
    /* Red/RG formats */
    case MESA_FORMAT_RED_RGTC1:
-      fetch = _mesa_fetch_texel_2d_f_red_rgtc1;
+      fetch = _mesa_fetch_texel_red_rgtc1;
       break;
    case MESA_FORMAT_SIGNED_RED_RGTC1:
-      fetch = _mesa_fetch_texel_2d_f_signed_red_rgtc1;
+      fetch = _mesa_fetch_texel_signed_red_rgtc1;
       break;
    case MESA_FORMAT_RG_RGTC2:
-      fetch = _mesa_fetch_texel_2d_f_rg_rgtc2;
+      fetch = _mesa_fetch_texel_rg_rgtc2;
       break;
    case MESA_FORMAT_SIGNED_RG_RGTC2:
-      fetch = _mesa_fetch_texel_2d_f_signed_rg_rgtc2;
+      fetch = _mesa_fetch_texel_signed_rg_rgtc2;
       break;
 
    /* L/LA formats */
    case MESA_FORMAT_L_LATC1:
-      fetch = _mesa_fetch_texel_2d_f_l_latc1;
+      fetch = _mesa_fetch_texel_l_latc1;
       break;
    case MESA_FORMAT_SIGNED_L_LATC1:
-      fetch = _mesa_fetch_texel_2d_f_signed_l_latc1;
+      fetch = _mesa_fetch_texel_signed_l_latc1;
       break;
    case MESA_FORMAT_LA_LATC2:
-      fetch = _mesa_fetch_texel_2d_f_la_latc2;
+      fetch = _mesa_fetch_texel_la_latc2;
       break;
    case MESA_FORMAT_SIGNED_LA_LATC2:
-      fetch = _mesa_fetch_texel_2d_f_signed_la_latc2;
+      fetch = _mesa_fetch_texel_signed_la_latc2;
       break;
 
    /* ETC1 formats */