swrast: use new core Mesa compressed texel fetch functions
authorBrian Paul <brianp@vmware.com>
Sat, 8 Dec 2012 22:19:44 +0000 (15:19 -0700)
committerBrian Paul <brianp@vmware.com>
Fri, 14 Dec 2012 13:33:08 +0000 (06:33 -0700)
src/mesa/swrast/s_context.h
src/mesa/swrast/s_texfetch.c

index 18353c4167b399b0ea24f711224cdba6fa299c64..f3f188e470f1c5e714725f4d9fe4b10fc630852e 100644 (file)
@@ -45,6 +45,7 @@
 
 #include "main/compiler.h"
 #include "main/mtypes.h"
+#include "main/texcompress.h"
 #include "program/prog_execute.h"
 #include "swrast.h"
 #include "s_fragprog.h"
@@ -146,6 +147,9 @@ struct swrast_texture_image
    GLubyte *Buffer;
 
    FetchTexelFunc FetchTexel;
+
+   /** For fetching texels from compressed textures */
+   compressed_fetch_func FetchCompressedTexel;
 };
 
 
index c133eac9b8141abc54f36e4745109ade7e132c32..1f1964172591878656124bbbb319e8846f24b86f 100644 (file)
@@ -88,6 +88,23 @@ nonlinear_to_linear(GLubyte cs8)
 #define DIM 3
 #include "s_texfetch_tmp.h"
 
+
+/**
+ * All compressed texture texel fetching is done though this function.
+ * Basically just call a core-Mesa texel fetch function.
+ */
+static void
+fetch_compressed(const struct swrast_texture_image *swImage,
+                 GLint i, GLint j, GLint k, GLfloat *texel)
+{
+   swImage->FetchCompressedTexel(swImage->Map,
+                                 swImage->ImageOffsets,
+                                 swImage->RowStride,
+                                 i, j, k, texel);
+}
+
+
+
 /**
  * Null texel fetch function.
  *
@@ -426,64 +443,64 @@ texfetch_funcs[] =
    },
    {
       MESA_FORMAT_SRGB_DXT1,
-      _mesa_fetch_texel_srgb_dxt1,
-      _mesa_fetch_texel_srgb_dxt1,
-      _mesa_fetch_texel_srgb_dxt1
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_SRGBA_DXT1,
-      _mesa_fetch_texel_srgba_dxt1,
-      _mesa_fetch_texel_srgba_dxt1,
-      _mesa_fetch_texel_srgba_dxt1
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_SRGBA_DXT3,
-      _mesa_fetch_texel_srgba_dxt3,
-      _mesa_fetch_texel_srgba_dxt3,
-      _mesa_fetch_texel_srgba_dxt3
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_SRGBA_DXT5,
-      _mesa_fetch_texel_srgba_dxt5,
-      _mesa_fetch_texel_srgba_dxt5,
-      _mesa_fetch_texel_srgba_dxt5
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
 
    {
       MESA_FORMAT_RGB_FXT1,
-      NULL,
-      _mesa_fetch_texel_2d_f_rgb_fxt1,
-      NULL
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_RGBA_FXT1,
-      NULL,
-      _mesa_fetch_texel_2d_f_rgba_fxt1,
-      NULL
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_RGB_DXT1,
-      _mesa_fetch_texel_rgb_dxt1,
-      _mesa_fetch_texel_rgb_dxt1,
-      _mesa_fetch_texel_rgb_dxt1
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_RGBA_DXT1,
-      _mesa_fetch_texel_rgba_dxt1,
-      _mesa_fetch_texel_rgba_dxt1,
-      _mesa_fetch_texel_rgba_dxt1
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_RGBA_DXT3,
-      _mesa_fetch_texel_rgba_dxt3,
-      _mesa_fetch_texel_rgba_dxt3,
-      _mesa_fetch_texel_rgba_dxt3
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_RGBA_DXT5,
-      _mesa_fetch_texel_rgba_dxt5,
-      _mesa_fetch_texel_rgba_dxt5,
-      _mesa_fetch_texel_rgba_dxt5
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_RGBA_FLOAT32,
@@ -976,117 +993,117 @@ texfetch_funcs[] =
    },
    {
       MESA_FORMAT_RED_RGTC1,
-      _mesa_fetch_texel_red_rgtc1,
-      _mesa_fetch_texel_red_rgtc1,
-      _mesa_fetch_texel_red_rgtc1
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_SIGNED_RED_RGTC1,
-      _mesa_fetch_texel_signed_red_rgtc1,
-      _mesa_fetch_texel_signed_red_rgtc1,
-      _mesa_fetch_texel_signed_red_rgtc1
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_RG_RGTC2,
-      _mesa_fetch_texel_rg_rgtc2,
-      _mesa_fetch_texel_rg_rgtc2,
-      _mesa_fetch_texel_rg_rgtc2
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_SIGNED_RG_RGTC2,
-      _mesa_fetch_texel_signed_rg_rgtc2,
-      _mesa_fetch_texel_signed_rg_rgtc2,
-      _mesa_fetch_texel_signed_rg_rgtc2
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_L_LATC1,
-      _mesa_fetch_texel_l_latc1,
-      _mesa_fetch_texel_l_latc1,
-      _mesa_fetch_texel_l_latc1
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_SIGNED_L_LATC1,
-      _mesa_fetch_texel_signed_l_latc1,
-      _mesa_fetch_texel_signed_l_latc1,
-      _mesa_fetch_texel_signed_l_latc1
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_LA_LATC2,
-      _mesa_fetch_texel_la_latc2,
-      _mesa_fetch_texel_la_latc2,
-      _mesa_fetch_texel_la_latc2
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_SIGNED_LA_LATC2,
-      _mesa_fetch_texel_signed_la_latc2,
-      _mesa_fetch_texel_signed_la_latc2,
-      _mesa_fetch_texel_signed_la_latc2
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_ETC1_RGB8,
-      NULL,
-      _mesa_fetch_texel_2d_f_etc1_rgb8,
-      NULL
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_ETC2_RGB8,
-      NULL,
-      _mesa_fetch_texel_2d_f_etc2_rgb8,
-      NULL
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_ETC2_SRGB8,
-      NULL,
-      _mesa_fetch_texel_2d_f_etc2_srgb8,
-      NULL
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_ETC2_RGBA8_EAC,
-      NULL,
-      _mesa_fetch_texel_2d_f_etc2_rgba8_eac,
-      NULL
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC,
-      NULL,
-      _mesa_fetch_texel_2d_f_etc2_srgb8_alpha8_eac,
-      NULL
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_ETC2_R11_EAC,
-      NULL,
-      _mesa_fetch_texel_2d_f_etc2_r11_eac,
-      NULL
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_ETC2_RG11_EAC,
-      NULL,
-      _mesa_fetch_texel_2d_f_etc2_rg11_eac,
-      NULL
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_ETC2_SIGNED_R11_EAC,
-      NULL,
-      _mesa_fetch_texel_2d_f_etc2_signed_r11_eac,
-      NULL
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_ETC2_SIGNED_RG11_EAC,
-      NULL,
-      _mesa_fetch_texel_2d_f_etc2_signed_rg11_eac,
-      NULL
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
-      NULL,
-      _mesa_fetch_texel_2d_f_etc2_rgb8_punchthrough_alpha1,
-      NULL
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
-      NULL,
-      _mesa_fetch_texel_2d_f_etc2_srgb8_punchthrough_alpha1,
-      NULL
+      fetch_compressed,
+      fetch_compressed,
+      fetch_compressed
    },
    {
       MESA_FORMAT_SIGNED_A8,
@@ -1215,6 +1232,8 @@ set_fetch_functions(const struct gl_sampler_object *samp,
       assert(!"Bad dims in set_fetch_functions()");
    }
 
+   texImage->FetchCompressedTexel = _mesa_get_compressed_fetch_func(format);
+
    ASSERT(texImage->FetchTexel);
 }