mesa: remove unused var
[mesa.git] / src / mesa / main / texfetch.c
index 8149166560e26ab98cc4079e8799527073eede81..b37039429f497408937f52bfef5bebf3bb2c686d 100644 (file)
@@ -41,8 +41,6 @@
 #include "texfetch.h"
 
 
-#if FEATURE_EXT_texture_sRGB
-
 /**
  * Convert an 8-bit sRGB value from non-linear space to a
  * linear RGB value in [0, 1].
@@ -71,19 +69,17 @@ nonlinear_to_linear(GLubyte cs8)
 }
 
 
-#endif /* FEATURE_EXT_texture_sRGB */
-
 
 /* Texel fetch routines for all supported formats
  */
 #define DIM 1
-#include "texformat_tmp.h"
+#include "texfetch_tmp.h"
 
 #define DIM 2
-#include "texformat_tmp.h"
+#include "texfetch_tmp.h"
 
 #define DIM 3
-#include "texformat_tmp.h"
+#include "texfetch_tmp.h"
 
 /**
  * Null texel fetch function.
@@ -337,6 +333,13 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
       fetch_texel_3d_signed_rgba8888_rev,
       store_texel_signed_rgba8888_rev
    },
+   {
+      MESA_FORMAT_SIGNED_RGBA_16,
+      NULL, /* XXX to do */
+      NULL,
+      NULL,
+      NULL
+   },
    {
       MESA_FORMAT_RGBA8888,
       fetch_texel_1d_f_rgba8888,
@@ -365,6 +368,20 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
       fetch_texel_3d_f_argb8888_rev,
       store_texel_argb8888_rev
    },
+   {
+      MESA_FORMAT_XRGB8888,
+      fetch_texel_1d_f_xrgb8888,
+      fetch_texel_2d_f_xrgb8888,
+      fetch_texel_3d_f_xrgb8888,
+      store_texel_xrgb8888
+   },
+   {
+      MESA_FORMAT_XRGB8888_REV,
+      fetch_texel_1d_f_xrgb8888_rev,
+      fetch_texel_2d_f_xrgb8888_rev,
+      fetch_texel_3d_f_xrgb8888_rev,
+      store_texel_xrgb8888_rev,
+   },
    {
       MESA_FORMAT_RGB888,
       fetch_texel_1d_f_rgb888,
@@ -393,13 +410,6 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
       fetch_texel_3d_f_rgb565_rev,
       store_texel_rgb565_rev
    },
-   {
-      MESA_FORMAT_RGBA4444,
-      fetch_texel_1d_f_rgba4444,
-      fetch_texel_2d_f_rgba4444,
-      fetch_texel_3d_f_rgba4444,
-      store_texel_rgba4444
-   },
    {
       MESA_FORMAT_ARGB4444,
       fetch_texel_1d_f_argb4444,
@@ -449,6 +459,20 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
       fetch_texel_3d_f_al88_rev,
       store_texel_al88_rev
    },
+   {
+      MESA_FORMAT_AL1616,
+      fetch_texel_1d_f_al1616,
+      fetch_texel_2d_f_al1616,
+      fetch_texel_3d_f_al1616,
+      store_texel_al1616
+   },
+   {
+      MESA_FORMAT_AL1616_REV,
+      fetch_texel_1d_f_al1616_rev,
+      fetch_texel_2d_f_al1616_rev,
+      fetch_texel_3d_f_al1616_rev,
+      store_texel_al1616_rev
+   },
    {
       MESA_FORMAT_RGB332,
       fetch_texel_1d_f_rgb332,
@@ -519,6 +543,20 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
       fetch_texel_3d_f_z16,
       store_texel_z16
    },
+   {
+      MESA_FORMAT_X8_Z24,
+      fetch_texel_1d_f_s8_z24,
+      fetch_texel_2d_f_s8_z24,
+      fetch_texel_3d_f_s8_z24,
+      store_texel_s8_z24
+   },
+   {
+      MESA_FORMAT_Z24_X8,
+      fetch_texel_1d_f_z24_s8,
+      fetch_texel_2d_f_z24_s8,
+      fetch_texel_3d_f_z24_s8,
+      store_texel_z24_s8
+   },
    {
       MESA_FORMAT_Z32,
       fetch_texel_1d_f_z32,
@@ -529,10 +567,10 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
 };
 
 
-FetchTexelFuncF
+static FetchTexelFuncF
 _mesa_get_texel_fetch_func(gl_format format, GLuint dims)
 {
-   FetchTexelFuncF f;
+   FetchTexelFuncF f = NULL;
    GLuint i;
    /* XXX replace loop with direct table lookup */
    for (i = 0; i < MESA_FORMAT_COUNT; i++) {
@@ -572,3 +610,84 @@ _mesa_get_texel_store_func(gl_format format)
    }
    return NULL;
 }
+
+
+
+/**
+ * Adaptor for fetching a GLchan texel from a float-valued texture.
+ */
+static void
+fetch_texel_float_to_chan(const struct gl_texture_image *texImage,
+                          GLint i, GLint j, GLint k, GLchan *texelOut)
+{
+   GLfloat temp[4];
+   GLenum baseFormat = _mesa_get_format_base_format(texImage->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 gl_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.
+ */
+void
+_mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims)
+{
+   ASSERT(dims == 1 || dims == 2 || dims == 3);
+   ASSERT(texImage->TexFormat);
+
+   if (!texImage->FetchTexelf) {
+      texImage->FetchTexelf =
+         _mesa_get_texel_fetch_func(texImage->TexFormat, dims);
+   }
+
+   /* now check if we need to use a float/chan adaptor */
+   if (!texImage->FetchTexelc) {
+      texImage->FetchTexelc = fetch_texel_float_to_chan;
+   }
+
+   ASSERT(texImage->FetchTexelc);
+   ASSERT(texImage->FetchTexelf);
+}