r600g: pad the DMA CS to a multiple of 8 dwords
[mesa.git] / src / mesa / main / texcompress_fxt1.c
index eafa187940e622157fc4c949af8c95ce8dc64403..f7254f92e29877ba1e7e5237451800dab5430b85 100644 (file)
 #include "texcompress.h"
 #include "texcompress_fxt1.h"
 #include "texstore.h"
-#include "swrast/s_context.h"
-
-
-#if FEATURE_texture_fxt1
 
 
 static void
@@ -50,7 +46,7 @@ fxt1_encode (GLuint width, GLuint height, GLint comps,
              const void *source, GLint srcRowStride,
              void *dest, GLint destRowStride);
 
-void
+static void
 fxt1_decode_1 (const void *texture, GLint stride,
                GLint i, GLint j, GLubyte *rgba);
 
@@ -99,8 +95,7 @@ _mesa_texstore_rgb_fxt1(TEXSTORE_PARAMS)
    fxt1_encode(srcWidth, srcHeight, 3, pixels, srcRowStride,
                dst, dstRowStride);
 
-   if (tempImage)
-      free((void*) tempImage);
+   free((void*) tempImage);
 
    return GL_TRUE;
 }
@@ -149,44 +144,12 @@ _mesa_texstore_rgba_fxt1(TEXSTORE_PARAMS)
    fxt1_encode(srcWidth, srcHeight, 4, pixels, srcRowStride,
                dst, dstRowStride);
 
-   if (tempImage)
-      free((void*) tempImage);
+   free((void*) tempImage);
 
    return GL_TRUE;
 }
 
 
-void
-_mesa_fetch_texel_2d_f_rgba_fxt1( const struct swrast_texture_image *texImage,
-                                  GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   /* just sample as GLubyte and convert to float here */
-   GLubyte rgba[4];
-   (void) k;
-   fxt1_decode_1(texImage->Map, texImage->RowStride, i, j, rgba);
-   texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
-   texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
-   texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
-   texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
-}
-
-
-void
-_mesa_fetch_texel_2d_f_rgb_fxt1( const struct swrast_texture_image *texImage,
-                                 GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   /* just sample as GLubyte and convert to float here */
-   GLubyte rgba[4];
-   (void) k;
-   fxt1_decode_1(texImage->Map, texImage->RowStride, i, j, rgba);
-   texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
-   texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
-   texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
-   texel[ACOMP] = 1.0F;
-}
-
-
-
 /***************************************************************************\
  * FXT1 encoder
  *
@@ -1363,9 +1326,7 @@ fxt1_encode (GLuint width, GLuint height, GLint comps,
    }
 
  cleanUp:
-   if (newSource != NULL) {
-      free(newSource);
-   }
+   free(newSource);
 }
 
 
@@ -1623,7 +1584,7 @@ fxt1_decode_1ALPHA (const GLubyte *code, GLint t, GLubyte *rgba)
 }
 
 
-void
+static void
 fxt1_decode_1 (const void *texture, GLint stride, /* in pixels */
                GLint i, GLint j, GLubyte *rgba)
 {
@@ -1652,4 +1613,43 @@ fxt1_decode_1 (const void *texture, GLint stride, /* in pixels */
 }
 
 
-#endif /* FEATURE_texture_fxt1 */
+
+
+static void
+fetch_rgb_fxt1(const GLubyte *map, const GLuint imageOffsets[],
+               GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
+{
+   GLubyte rgba[4];
+   fxt1_decode_1(map, rowStride, i, j, rgba);
+   texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
+   texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
+   texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
+   texel[ACOMP] = 1.0F;
+}
+
+
+static void
+fetch_rgba_fxt1(const GLubyte *map, const GLuint imageOffsets[],
+                GLint rowStride, GLint i, GLint j, GLint k, GLfloat *texel)
+{
+   GLubyte rgba[4];
+   fxt1_decode_1(map, rowStride, i, j, rgba);
+   texel[RCOMP] = UBYTE_TO_FLOAT(rgba[RCOMP]);
+   texel[GCOMP] = UBYTE_TO_FLOAT(rgba[GCOMP]);
+   texel[BCOMP] = UBYTE_TO_FLOAT(rgba[BCOMP]);
+   texel[ACOMP] = UBYTE_TO_FLOAT(rgba[ACOMP]);
+}
+
+
+compressed_fetch_func
+_mesa_get_fxt_fetch_func(gl_format format)
+{
+   switch (format) {
+   case MESA_FORMAT_RGB_FXT1:
+      return fetch_rgb_fxt1;
+   case MESA_FORMAT_RGBA_FXT1:
+      return fetch_rgba_fxt1;
+   default:
+      return NULL;
+   }
+}