swrast: remove dstType param from _swrast_read_rgba_span()
[mesa.git] / src / mesa / swrast / s_texfetch.c
index 7573abda6ddf436766594807dbed1f4d5d67f2c8..7cb6e68b1c790c12c4484b945fb732b388d954d8 100644 (file)
@@ -39,6 +39,7 @@
 #include "main/texcompress_fxt1.h"
 #include "main/texcompress_s3tc.h"
 #include "main/texcompress_rgtc.h"
+#include "main/texcompress_etc.h"
 #include "main/teximage.h"
 #include "s_context.h"
 #include "s_texfetch.h"
@@ -121,9 +122,9 @@ static void store_null_texel(struct swrast_texture_image *texImage,
  */
 static struct {
    gl_format Name;
-   FetchTexelFuncF Fetch1D;
-   FetchTexelFuncF Fetch2D;
-   FetchTexelFuncF Fetch3D;
+   FetchTexelFunc Fetch1D;
+   FetchTexelFunc Fetch2D;
+   FetchTexelFunc Fetch3D;
    StoreTexelFunc StoreTexel;
 }
 texfetch_funcs[MESA_FORMAT_COUNT] =
@@ -164,6 +165,20 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
       fetch_texel_3d_f_argb8888_rev,
       store_texel_argb8888_rev
    },
+   {
+      MESA_FORMAT_RGBX8888,
+      fetch_texel_1d_f_rgbx8888,
+      fetch_texel_2d_f_rgbx8888,
+      fetch_texel_3d_f_rgbx8888,
+      store_texel_rgbx8888
+   },
+   {
+      MESA_FORMAT_RGBX8888_REV,
+      fetch_texel_1d_f_rgbx8888_rev,
+      fetch_texel_2d_f_rgbx8888_rev,
+      fetch_texel_3d_f_rgbx8888_rev,
+      store_texel_rgbx8888_rev,
+   },
    {
       MESA_FORMAT_XRGB8888,
       fetch_texel_1d_f_xrgb8888,
@@ -346,6 +361,13 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
       fetch_texel_3d_f_r8,
       store_texel_r8,
    },
+   {
+      MESA_FORMAT_GR88,
+      fetch_texel_1d_f_gr88,
+      fetch_texel_2d_f_gr88,
+      fetch_texel_3d_f_gr88,
+      store_texel_gr88,
+   },
    {
       MESA_FORMAT_RG88,
       fetch_texel_1d_f_rg88,
@@ -353,13 +375,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
       fetch_texel_3d_f_rg88,
       store_texel_rg88,
    },
-   {
-      MESA_FORMAT_RG88_REV,
-      fetch_texel_1d_f_rg88_rev,
-      fetch_texel_2d_f_rg88_rev,
-      fetch_texel_3d_f_rg88_rev,
-      store_texel_rg88_rev,
-   },
    {
       MESA_FORMAT_R16,
       fetch_texel_1d_f_r16,
@@ -1163,6 +1178,13 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
       NULL,
       NULL
    },
+   {
+      MESA_FORMAT_ETC1_RGB8,
+      NULL,
+      _mesa_fetch_texel_2d_f_etc1_rgb8,
+      NULL,
+      NULL
+   },
    {
       MESA_FORMAT_SIGNED_A8,
       fetch_texel_1d_signed_a8,
@@ -1246,11 +1268,18 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
       fetch_texel_2d_z32f_x24s8,
       fetch_texel_3d_z32f_x24s8,
       store_texel_z32f_x24s8
+   },
+   {
+      MESA_FORMAT_ARGB2101010_UINT,
+      NULL,
+      NULL,
+      NULL,
+      NULL
    }
 };
 
 
-FetchTexelFuncF
+FetchTexelFunc
 _mesa_get_texel_fetch_func(gl_format format, GLuint dims)
 {
 #ifdef DEBUG
@@ -1261,7 +1290,8 @@ _mesa_get_texel_fetch_func(gl_format format, GLuint dims)
    }
 #endif
 
-   assert(Elements(texfetch_funcs) == MESA_FORMAT_COUNT);
+   STATIC_ASSERT(Elements(texfetch_funcs) == MESA_FORMAT_COUNT);
+
    assert(format < MESA_FORMAT_COUNT);
 
    switch (dims) {
@@ -1287,63 +1317,7 @@ _mesa_get_texel_store_func(gl_format format)
 
 
 /**
- * Adaptor for fetching a GLchan texel from a float-valued texture.
- */
-static void
-fetch_texel_float_to_chan(const struct swrast_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLchan *texelOut)
-{
-   GLfloat temp[4];
-   GLenum baseFormat = _mesa_get_format_base_format(texImage->Base.TexFormat);
-
-   ASSERT(texImage->FetchTexelf);
-   texImage->FetchTexelf(texImage, i, j, k, temp);
-   if (baseFormat == GL_DEPTH_COMPONENT ||
-       baseFormat == GL_DEPTH_STENCIL_EXT) {
-      /* just one channel */
-      UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]);
-   }
-   else {
-      /* four channels */
-      UNCLAMPED_FLOAT_TO_CHAN(texelOut[0], temp[0]);
-      UNCLAMPED_FLOAT_TO_CHAN(texelOut[1], temp[1]);
-      UNCLAMPED_FLOAT_TO_CHAN(texelOut[2], temp[2]);
-      UNCLAMPED_FLOAT_TO_CHAN(texelOut[3], temp[3]);
-   }
-}
-
-
-#if 0
-/**
- * Adaptor for fetching a float texel from a GLchan-valued texture.
- */
-static void
-fetch_texel_chan_to_float(const struct swrast_texture_image *texImage,
-                          GLint i, GLint j, GLint k, GLfloat *texelOut)
-{
-   GLchan temp[4];
-   GLenum baseFormat = _mesa_get_format_base_format(texImage->TexFormat);
-
-   ASSERT(texImage->FetchTexelc);
-   texImage->FetchTexelc(texImage, i, j, k, temp);
-   if (baseFormat == GL_DEPTH_COMPONENT ||
-       baseFormat == GL_DEPTH_STENCIL_EXT) {
-      /* just one channel */
-      texelOut[0] = CHAN_TO_FLOAT(temp[0]);
-   }
-   else {
-      /* four channels */
-      texelOut[0] = CHAN_TO_FLOAT(temp[0]);
-      texelOut[1] = CHAN_TO_FLOAT(temp[1]);
-      texelOut[2] = CHAN_TO_FLOAT(temp[2]);
-      texelOut[3] = CHAN_TO_FLOAT(temp[3]);
-   }
-}
-#endif
-
-
-/**
- * Initialize the texture image's FetchTexelc and FetchTexelf methods.
+ * Initialize the texture image's FetchTexel methods.
  */
 static void
 set_fetch_functions(struct swrast_texture_image *texImage, GLuint dims)
@@ -1357,12 +1331,8 @@ set_fetch_functions(struct swrast_texture_image *texImage, GLuint dims)
       format = _mesa_get_srgb_format_linear(format);
    }
 
-   texImage->FetchTexelf = _mesa_get_texel_fetch_func(format, dims);
-
-   texImage->FetchTexelc = fetch_texel_float_to_chan;
-
-   ASSERT(texImage->FetchTexelc);
-   ASSERT(texImage->FetchTexelf);
+   texImage->FetchTexel = _mesa_get_texel_fetch_func(format, dims);
+   ASSERT(texImage->FetchTexel);
 }
 
 void