mesa: move texel fetch/store into new texfetch.[ch] files
authorBrian Paul <brianp@vmware.com>
Thu, 1 Oct 2009 02:47:54 +0000 (20:47 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 1 Oct 2009 02:47:54 +0000 (20:47 -0600)
src/mesa/SConscript
src/mesa/main/texfetch.c [new file with mode: 0644]
src/mesa/main/texfetch.h [new file with mode: 0644]
src/mesa/main/texformat.c
src/mesa/main/texformat.h
src/mesa/main/texrender.c
src/mesa/main/texstore.c
src/mesa/sources.mak
windows/VC7/mesa/mesa/mesa.vcproj
windows/VC8/mesa/mesa/mesa.vcproj

index 6dfbd26d94adb90a81957c0ec9ae040fde6f5dd4..8066da729b2bba5ef8cb9bcb59a1939b71d2e614 100644 (file)
@@ -91,6 +91,7 @@ if env['platform'] != 'winddk':
                'main/texcompress_fxt1.c',
                'main/texenv.c',
                'main/texenvprogram.c',
+               'main/texfetch.c',
                'main/texformat.c',
                'main/texgen.c',
                'main/texgetimage.c',
diff --git a/src/mesa/main/texfetch.c b/src/mesa/main/texfetch.c
new file mode 100644 (file)
index 0000000..20ee252
--- /dev/null
@@ -0,0 +1,616 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.7
+ *
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (c) 2009  VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+/**
+ * \file texfetch.c
+ *
+ * Texel fetch/store functions
+ *
+ * \author Gareth Hughes
+ */
+
+
+#include "colormac.h"
+#include "context.h"
+#include "texcompress.h"
+#include "texcompress_fxt1.h"
+#include "texcompress_s3tc.h"
+#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].
+ * Implemented with a 256-entry lookup table.
+ */
+static INLINE GLfloat
+nonlinear_to_linear(GLubyte cs8)
+{
+   static GLfloat table[256];
+   static GLboolean tableReady = GL_FALSE;
+   if (!tableReady) {
+      /* compute lookup table now */
+      GLuint i;
+      for (i = 0; i < 256; i++) {
+         const GLfloat cs = UBYTE_TO_FLOAT(i);
+         if (cs <= 0.04045) {
+            table[i] = cs / 12.92f;
+         }
+         else {
+            table[i] = (GLfloat) _mesa_pow((cs + 0.055) / 1.055, 2.4);
+         }
+      }
+      tableReady = GL_TRUE;
+   }
+   return table[cs8];
+}
+
+
+#endif /* FEATURE_EXT_texture_sRGB */
+
+
+/* Texel fetch routines for all supported formats
+ */
+#define DIM 1
+#include "texformat_tmp.h"
+
+#define DIM 2
+#include "texformat_tmp.h"
+
+#define DIM 3
+#include "texformat_tmp.h"
+
+/**
+ * Null texel fetch function.
+ *
+ * Have to have this so the FetchTexel function pointer is never NULL.
+ */
+static void fetch_null_texelf( const struct gl_texture_image *texImage,
+                               GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   (void) texImage; (void) i; (void) j; (void) k;
+   texel[RCOMP] = 0.0;
+   texel[GCOMP] = 0.0;
+   texel[BCOMP] = 0.0;
+   texel[ACOMP] = 0.0;
+   _mesa_warning(NULL, "fetch_null_texelf() called!");
+}
+
+static void store_null_texel(struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, const void *texel)
+{
+   (void) texImage;
+   (void) i;
+   (void) j;
+   (void) k;
+   (void) texel;
+   /* no-op */
+}
+
+
+
+/**
+ * Table to map MESA_FORMAT_ to texel fetch/store funcs.
+ * XXX this is somewhat temporary.
+ */
+static struct {
+   GLuint Name;
+   FetchTexelFuncF Fetch1D;
+   FetchTexelFuncF Fetch2D;
+   FetchTexelFuncF Fetch3D;
+   StoreTexelFunc StoreTexel;
+}
+texfetch_funcs[MESA_FORMAT_COUNT] =
+{
+   {
+      MESA_FORMAT_RGBA,
+      fetch_texel_1d_f_rgba,
+      fetch_texel_2d_f_rgba,
+      fetch_texel_3d_f_rgba,
+      store_texel_rgba
+   },
+   {
+      MESA_FORMAT_RGB,
+      fetch_texel_1d_f_rgb,
+      fetch_texel_2d_f_rgb,
+      fetch_texel_3d_f_rgb,
+      store_texel_rgb
+   },
+   {
+      MESA_FORMAT_ALPHA,
+      fetch_texel_1d_f_alpha,
+      fetch_texel_2d_f_alpha,
+      fetch_texel_3d_f_alpha,
+      store_texel_alpha
+   },
+   {
+      MESA_FORMAT_LUMINANCE,
+      fetch_texel_1d_f_luminance,
+      fetch_texel_2d_f_luminance,
+      fetch_texel_3d_f_luminance,
+      store_texel_luminance
+   },
+   {
+      MESA_FORMAT_LUMINANCE_ALPHA,
+      fetch_texel_1d_f_luminance_alpha,
+      fetch_texel_2d_f_luminance_alpha,
+      fetch_texel_3d_f_luminance_alpha,
+      store_texel_luminance_alpha
+   },
+   {
+      MESA_FORMAT_INTENSITY,
+      fetch_texel_1d_f_intensity,
+      fetch_texel_2d_f_intensity,
+      fetch_texel_3d_f_intensity,
+      store_texel_intensity
+   },
+   {
+      MESA_FORMAT_SRGB8,
+      fetch_texel_1d_srgb8,
+      fetch_texel_2d_srgb8,
+      fetch_texel_3d_srgb8,
+      store_texel_srgb8
+   },
+   {
+      MESA_FORMAT_SRGBA8,
+      fetch_texel_1d_srgba8,
+      fetch_texel_2d_srgba8,
+      fetch_texel_3d_srgba8,
+      store_texel_srgba8
+   },
+   {
+      MESA_FORMAT_SARGB8,
+      fetch_texel_1d_sargb8,
+      fetch_texel_2d_sargb8,
+      fetch_texel_3d_sargb8,
+      store_texel_sargb8
+   },
+   {
+      MESA_FORMAT_SL8,
+      fetch_texel_1d_sl8,
+      fetch_texel_2d_sl8,
+      fetch_texel_3d_sl8,
+      store_texel_sl8
+   },
+   {
+      MESA_FORMAT_SLA8,
+      fetch_texel_1d_sla8,
+      fetch_texel_2d_sla8,
+      fetch_texel_3d_sla8,
+      store_texel_sla8
+   },
+   {
+      MESA_FORMAT_RGB_FXT1,
+      NULL,
+      _mesa_fetch_texel_2d_f_rgb_fxt1,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_RGBA_FXT1,
+      NULL,
+      _mesa_fetch_texel_2d_f_rgba_fxt1,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_RGB_DXT1,
+      NULL,
+      _mesa_fetch_texel_2d_f_rgb_dxt1,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_RGBA_DXT1,
+      NULL,
+      _mesa_fetch_texel_2d_f_rgba_dxt1,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_RGBA_DXT3,
+      NULL,
+      _mesa_fetch_texel_2d_f_rgba_dxt3,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_RGBA_DXT5,
+      NULL,
+      _mesa_fetch_texel_2d_f_rgba_dxt5,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_SRGB_DXT1,
+      NULL,
+      _mesa_fetch_texel_2d_f_srgb_dxt1,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_SRGBA_DXT1,
+      NULL,
+      _mesa_fetch_texel_2d_f_srgba_dxt1,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_SRGBA_DXT3,
+      NULL,
+      _mesa_fetch_texel_2d_f_srgba_dxt3,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_SRGBA_DXT5,
+      NULL,
+      _mesa_fetch_texel_2d_f_srgba_dxt5,
+      NULL,
+      NULL
+   },
+   {
+      MESA_FORMAT_RGBA_FLOAT32,
+      fetch_texel_1d_f_rgba_f32,
+      fetch_texel_2d_f_rgba_f32,
+      fetch_texel_3d_f_rgba_f32,
+      store_texel_rgba_f32
+   },
+   {
+      MESA_FORMAT_RGBA_FLOAT16,
+      fetch_texel_1d_f_rgba_f16,
+      fetch_texel_2d_f_rgba_f16,
+      fetch_texel_3d_f_rgba_f16,
+      store_texel_rgba_f16
+   },
+   {
+      MESA_FORMAT_RGB_FLOAT32,
+      fetch_texel_1d_f_rgb_f32,
+      fetch_texel_2d_f_rgb_f32,
+      fetch_texel_3d_f_rgb_f32,
+      store_texel_rgb_f32
+   },
+   {
+      MESA_FORMAT_RGB_FLOAT16,
+      fetch_texel_1d_f_rgb_f16,
+      fetch_texel_2d_f_rgb_f16,
+      fetch_texel_3d_f_rgb_f16,
+      store_texel_rgb_f16
+   },
+   {
+      MESA_FORMAT_ALPHA_FLOAT32,
+      fetch_texel_1d_f_alpha_f32,
+      fetch_texel_2d_f_alpha_f32,
+      fetch_texel_3d_f_alpha_f32,
+      store_texel_alpha_f32
+   },
+   {
+      MESA_FORMAT_ALPHA_FLOAT16,
+      fetch_texel_1d_f_alpha_f16,
+      fetch_texel_2d_f_alpha_f16,
+      fetch_texel_3d_f_alpha_f16,
+      store_texel_alpha_f16
+   },
+   {
+      MESA_FORMAT_LUMINANCE_FLOAT32,
+      fetch_texel_1d_f_luminance_f32,
+      fetch_texel_2d_f_luminance_f32,
+      fetch_texel_3d_f_luminance_f32,
+      store_texel_luminance_f32
+   },
+   {
+      MESA_FORMAT_LUMINANCE_FLOAT16,
+      fetch_texel_1d_f_luminance_f16,
+      fetch_texel_2d_f_luminance_f16,
+      fetch_texel_3d_f_luminance_f16,
+      store_texel_luminance_f16
+   },
+   {
+      MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
+      fetch_texel_1d_f_luminance_alpha_f32,
+      fetch_texel_2d_f_luminance_alpha_f32,
+      fetch_texel_3d_f_luminance_alpha_f32,
+      store_texel_luminance_alpha_f32
+   },
+   {
+      MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
+      fetch_texel_1d_f_luminance_alpha_f16,
+      fetch_texel_2d_f_luminance_alpha_f16,
+      fetch_texel_3d_f_luminance_alpha_f16,
+      store_texel_luminance_alpha_f16
+   },
+   {
+      MESA_FORMAT_INTENSITY_FLOAT32,
+      fetch_texel_1d_f_intensity_f32,
+      fetch_texel_2d_f_intensity_f32,
+      fetch_texel_3d_f_intensity_f32,
+      store_texel_intensity_f32
+   },
+   {
+      MESA_FORMAT_INTENSITY_FLOAT16,
+      fetch_texel_1d_f_intensity_f16,
+      fetch_texel_2d_f_intensity_f16,
+      fetch_texel_3d_f_intensity_f16,
+      store_texel_intensity_f16
+   },
+   {
+      MESA_FORMAT_DUDV8,
+      fetch_texel_1d_dudv8,
+      fetch_texel_2d_dudv8,
+      fetch_texel_3d_dudv8,
+      NULL
+   },
+   {
+      MESA_FORMAT_SIGNED_RGBA8888,
+      fetch_texel_1d_signed_rgba8888,
+      fetch_texel_2d_signed_rgba8888,
+      fetch_texel_3d_signed_rgba8888,
+      store_texel_signed_rgba8888
+   },
+   {
+      MESA_FORMAT_SIGNED_RGBA8888_REV,
+      fetch_texel_1d_signed_rgba8888_rev,
+      fetch_texel_2d_signed_rgba8888_rev,
+      fetch_texel_3d_signed_rgba8888_rev,
+      store_texel_signed_rgba8888_rev
+   },
+   {
+      MESA_FORMAT_RGBA8888,
+      fetch_texel_1d_f_rgba8888,
+      fetch_texel_2d_f_rgba8888,
+      fetch_texel_3d_f_rgba8888,
+      store_texel_rgba8888
+   },
+   {
+      MESA_FORMAT_RGBA8888_REV,
+      fetch_texel_1d_f_rgba8888_rev,
+      fetch_texel_2d_f_rgba8888_rev,
+      fetch_texel_3d_f_rgba8888_rev,
+      store_texel_rgba8888_rev
+   },
+   {
+      MESA_FORMAT_ARGB8888,
+      fetch_texel_1d_f_argb8888,
+      fetch_texel_2d_f_argb8888,
+      fetch_texel_3d_f_argb8888,
+      store_texel_argb8888
+   },
+   {
+      MESA_FORMAT_ARGB8888_REV,
+      fetch_texel_1d_f_argb8888_rev,
+      fetch_texel_2d_f_argb8888_rev,
+      fetch_texel_3d_f_argb8888_rev,
+      store_texel_argb8888_rev
+   },
+   {
+      MESA_FORMAT_RGB888,
+      fetch_texel_1d_f_rgb888,
+      fetch_texel_2d_f_rgb888,
+      fetch_texel_3d_f_rgb888,
+      store_texel_rgb888
+   },
+   {
+      MESA_FORMAT_BGR888,
+      fetch_texel_1d_f_bgr888,
+      fetch_texel_2d_f_bgr888,
+      fetch_texel_3d_f_bgr888,
+      store_texel_bgr888
+   },
+   {
+      MESA_FORMAT_RGB565,
+      fetch_texel_1d_f_rgb565,
+      fetch_texel_2d_f_rgb565,
+      fetch_texel_3d_f_rgb565,
+      store_texel_rgb565
+   },
+   {
+      MESA_FORMAT_RGB565_REV,
+      fetch_texel_1d_f_rgb565_rev,
+      fetch_texel_2d_f_rgb565_rev,
+      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,
+      fetch_texel_2d_f_argb4444,
+      fetch_texel_3d_f_argb4444,
+      store_texel_argb4444
+   },
+   {
+      MESA_FORMAT_ARGB4444_REV,
+      fetch_texel_1d_f_argb4444_rev,
+      fetch_texel_2d_f_argb4444_rev,
+      fetch_texel_3d_f_argb4444_rev,
+      store_texel_argb4444_rev
+   },
+   {
+      MESA_FORMAT_RGBA5551,
+      fetch_texel_1d_f_rgba5551,
+      fetch_texel_2d_f_rgba5551,
+      fetch_texel_3d_f_rgba5551,
+      store_texel_rgba5551
+   },
+   {
+      MESA_FORMAT_ARGB1555,
+      fetch_texel_1d_f_argb1555,
+      fetch_texel_2d_f_argb1555,
+      fetch_texel_3d_f_argb1555,
+      store_texel_argb1555
+   },
+   {
+      MESA_FORMAT_ARGB1555_REV,
+      fetch_texel_1d_f_argb1555_rev,
+      fetch_texel_2d_f_argb1555_rev,
+      fetch_texel_3d_f_argb1555_rev,
+      store_texel_argb1555_rev
+   },
+   {
+      MESA_FORMAT_AL88,
+      fetch_texel_1d_f_al88,
+      fetch_texel_2d_f_al88,
+      fetch_texel_3d_f_al88,
+      store_texel_al88
+   },
+   {
+      MESA_FORMAT_AL88_REV,
+      fetch_texel_1d_f_al88_rev,
+      fetch_texel_2d_f_al88_rev,
+      fetch_texel_3d_f_al88_rev,
+      store_texel_al88_rev
+   },
+   {
+      MESA_FORMAT_RGB332,
+      fetch_texel_1d_f_rgb332,
+      fetch_texel_2d_f_rgb332,
+      fetch_texel_3d_f_rgb332,
+      store_texel_rgb332
+   },
+   {
+      MESA_FORMAT_A8,
+      fetch_texel_1d_f_a8,
+      fetch_texel_2d_f_a8,
+      fetch_texel_3d_f_a8,
+      store_texel_a8
+   },
+   {
+      MESA_FORMAT_L8,
+      fetch_texel_1d_f_l8,
+      fetch_texel_2d_f_l8,
+      fetch_texel_3d_f_l8,
+      store_texel_l8
+   },
+   {
+      MESA_FORMAT_I8,
+      fetch_texel_1d_f_i8,
+      fetch_texel_2d_f_i8,
+      fetch_texel_3d_f_i8,
+      store_texel_i8
+   },
+   {
+      MESA_FORMAT_CI8,
+      fetch_texel_1d_f_ci8,
+      fetch_texel_2d_f_ci8,
+      fetch_texel_3d_f_ci8,
+      store_texel_ci8
+   },
+   {
+      MESA_FORMAT_YCBCR,
+      fetch_texel_1d_f_ycbcr,
+      fetch_texel_2d_f_ycbcr,
+      fetch_texel_3d_f_ycbcr,
+      store_texel_ycbcr
+   },
+   {
+      MESA_FORMAT_YCBCR_REV,
+      fetch_texel_1d_f_ycbcr_rev,
+      fetch_texel_2d_f_ycbcr_rev,
+      fetch_texel_3d_f_ycbcr_rev,
+      store_texel_ycbcr_rev
+   },
+   {
+      MESA_FORMAT_Z24_S8,
+      fetch_texel_1d_f_z24_s8,
+      fetch_texel_2d_f_z24_s8,
+      fetch_texel_3d_f_z24_s8,
+      store_texel_z24_s8
+   },
+   {
+      MESA_FORMAT_S8_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_Z16,
+      fetch_texel_1d_f_z16,
+      fetch_texel_2d_f_z16,
+      fetch_texel_3d_f_z16,
+      store_texel_z16
+   },
+   {
+      MESA_FORMAT_Z32,
+      fetch_texel_1d_f_z32,
+      fetch_texel_2d_f_z32,
+      fetch_texel_3d_f_z32,
+      store_texel_z32
+   }
+};
+
+
+FetchTexelFuncF
+_mesa_get_texel_fetch_func(gl_format format, GLuint dims)
+{
+   FetchTexelFuncF f;
+   GLuint i;
+   /* XXX replace loop with direct table lookup */
+   for (i = 0; i < MESA_FORMAT_COUNT; i++) {
+      if (texfetch_funcs[i].Name == format) {
+         switch (dims) {
+         case 1:
+            f = texfetch_funcs[i].Fetch1D;
+            break;
+         case 2:
+            f = texfetch_funcs[i].Fetch2D;
+            break;
+         case 3:
+            f = texfetch_funcs[i].Fetch3D;
+            break;
+         }
+         if (!f)
+            f = fetch_null_texelf;
+         return f;
+      }
+   }
+   return NULL;
+}
+
+
+StoreTexelFunc
+_mesa_get_texel_store_func(gl_format format)
+{
+   GLuint i;
+   /* XXX replace loop with direct table lookup */
+   for (i = 0; i < MESA_FORMAT_COUNT; i++) {
+      if (texfetch_funcs[i].Name == format) {
+         if (texfetch_funcs[i].StoreTexel)
+            return texfetch_funcs[i].StoreTexel;
+         else
+            return store_null_texel;
+      }
+   }
+   return NULL;
+}
diff --git a/src/mesa/main/texfetch.h b/src/mesa/main/texfetch.h
new file mode 100644 (file)
index 0000000..a397b04
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * Mesa 3-D graphics library
+ * Version:  7.7
+ *
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (c) 2009 VMware, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included
+ * in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+ * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+
+#ifndef TEXFETCH_H
+#define TEXFETCH_H
+
+#include "mtypes.h"
+#include "formats.h"
+
+
+extern FetchTexelFuncF
+_mesa_get_texel_fetch_func(gl_format format, GLuint dims);
+
+extern StoreTexelFunc
+_mesa_get_texel_store_func(gl_format format);
+
+
+#endif
index 9290210b3f99779853a08b838b0a29f1773f101f..bee7f583cf968cfe6db7bd23ccbf05a0a6a3a445 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.1
+ * Version:  7.7
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
- * Copyright (c) 2008 VMware, Inc.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (c) 2008-2009 VMware, Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * Texture formats.
  *
  * \author Gareth Hughes
+ * \author Brian Paul
  */
 
 
-#include "colormac.h"
 #include "context.h"
 #include "texcompress.h"
 #include "texcompress_fxt1.h"
 #include "texcompress_s3tc.h"
 #include "texformat.h"
-#include "texstore.h"
-
-
-#if FEATURE_EXT_texture_sRGB
-
-/**
- * Convert an 8-bit sRGB value from non-linear space to a
- * linear RGB value in [0, 1].
- * Implemented with a 256-entry lookup table.
- */
-static INLINE GLfloat
-nonlinear_to_linear(GLubyte cs8)
-{
-   static GLfloat table[256];
-   static GLboolean tableReady = GL_FALSE;
-   if (!tableReady) {
-      /* compute lookup table now */
-      GLuint i;
-      for (i = 0; i < 256; i++) {
-         const GLfloat cs = UBYTE_TO_FLOAT(i);
-         if (cs <= 0.04045) {
-            table[i] = cs / 12.92f;
-         }
-         else {
-            table[i] = (GLfloat) _mesa_pow((cs + 0.055) / 1.055, 2.4);
-         }
-      }
-      tableReady = GL_TRUE;
-   }
-   return table[cs8];
-}
-
-
-#endif /* FEATURE_EXT_texture_sRGB */
-
-
-/* Texel fetch routines for all supported formats
- */
-#define DIM 1
-#include "texformat_tmp.h"
-
-#define DIM 2
-#include "texformat_tmp.h"
-
-#define DIM 3
-#include "texformat_tmp.h"
-
-/**
- * Null texel fetch function.
- *
- * Have to have this so the FetchTexel function pointer is never NULL.
- */
-static void fetch_null_texelf( const struct gl_texture_image *texImage,
-                               GLint i, GLint j, GLint k, GLfloat *texel )
-{
-   (void) texImage; (void) i; (void) j; (void) k;
-   texel[RCOMP] = 0.0;
-   texel[GCOMP] = 0.0;
-   texel[BCOMP] = 0.0;
-   texel[ACOMP] = 0.0;
-   _mesa_warning(NULL, "fetch_null_texelf() called!");
-}
-
-static void store_null_texel(struct gl_texture_image *texImage,
-                             GLint i, GLint j, GLint k, const void *texel)
-{
-   (void) texImage;
-   (void) i;
-   (void) j;
-   (void) k;
-   (void) texel;
-   /* no-op */
-}
 
 
 /**
@@ -639,506 +566,3 @@ _mesa_format_to_type_and_comps(gl_format format,
       *comps = 1;
    }
 }
-
-
-
-/**
- * Table to map MESA_FORMAT_ to texel fetch/store funcs.
- * XXX this is somewhat temporary.
- */
-static struct {
-   GLuint Name;
-   FetchTexelFuncF Fetch1D;
-   FetchTexelFuncF Fetch2D;
-   FetchTexelFuncF Fetch3D;
-   StoreTexelFunc StoreTexel;
-}
-texfetch_funcs[MESA_FORMAT_COUNT] =
-{
-   {
-      MESA_FORMAT_RGBA,
-      fetch_texel_1d_f_rgba,
-      fetch_texel_2d_f_rgba,
-      fetch_texel_3d_f_rgba,
-      store_texel_rgba
-   },
-   {
-      MESA_FORMAT_RGB,
-      fetch_texel_1d_f_rgb,
-      fetch_texel_2d_f_rgb,
-      fetch_texel_3d_f_rgb,
-      store_texel_rgb
-   },
-   {
-      MESA_FORMAT_ALPHA,
-      fetch_texel_1d_f_alpha,
-      fetch_texel_2d_f_alpha,
-      fetch_texel_3d_f_alpha,
-      store_texel_alpha
-   },
-   {
-      MESA_FORMAT_LUMINANCE,
-      fetch_texel_1d_f_luminance,
-      fetch_texel_2d_f_luminance,
-      fetch_texel_3d_f_luminance,
-      store_texel_luminance
-   },
-   {
-      MESA_FORMAT_LUMINANCE_ALPHA,
-      fetch_texel_1d_f_luminance_alpha,
-      fetch_texel_2d_f_luminance_alpha,
-      fetch_texel_3d_f_luminance_alpha,
-      store_texel_luminance_alpha
-   },
-   {
-      MESA_FORMAT_INTENSITY,
-      fetch_texel_1d_f_intensity,
-      fetch_texel_2d_f_intensity,
-      fetch_texel_3d_f_intensity,
-      store_texel_intensity
-   },
-   {
-      MESA_FORMAT_SRGB8,
-      fetch_texel_1d_srgb8,
-      fetch_texel_2d_srgb8,
-      fetch_texel_3d_srgb8,
-      store_texel_srgb8
-   },
-   {
-      MESA_FORMAT_SRGBA8,
-      fetch_texel_1d_srgba8,
-      fetch_texel_2d_srgba8,
-      fetch_texel_3d_srgba8,
-      store_texel_srgba8
-   },
-   {
-      MESA_FORMAT_SARGB8,
-      fetch_texel_1d_sargb8,
-      fetch_texel_2d_sargb8,
-      fetch_texel_3d_sargb8,
-      store_texel_sargb8
-   },
-   {
-      MESA_FORMAT_SL8,
-      fetch_texel_1d_sl8,
-      fetch_texel_2d_sl8,
-      fetch_texel_3d_sl8,
-      store_texel_sl8
-   },
-   {
-      MESA_FORMAT_SLA8,
-      fetch_texel_1d_sla8,
-      fetch_texel_2d_sla8,
-      fetch_texel_3d_sla8,
-      store_texel_sla8
-   },
-   {
-      MESA_FORMAT_RGB_FXT1,
-      NULL,
-      _mesa_fetch_texel_2d_f_rgb_fxt1,
-      NULL,
-      NULL
-   },
-   {
-      MESA_FORMAT_RGBA_FXT1,
-      NULL,
-      _mesa_fetch_texel_2d_f_rgba_fxt1,
-      NULL,
-      NULL
-   },
-   {
-      MESA_FORMAT_RGB_DXT1,
-      NULL,
-      _mesa_fetch_texel_2d_f_rgb_dxt1,
-      NULL,
-      NULL
-   },
-   {
-      MESA_FORMAT_RGBA_DXT1,
-      NULL,
-      _mesa_fetch_texel_2d_f_rgba_dxt1,
-      NULL,
-      NULL
-   },
-   {
-      MESA_FORMAT_RGBA_DXT3,
-      NULL,
-      _mesa_fetch_texel_2d_f_rgba_dxt3,
-      NULL,
-      NULL
-   },
-   {
-      MESA_FORMAT_RGBA_DXT5,
-      NULL,
-      _mesa_fetch_texel_2d_f_rgba_dxt5,
-      NULL,
-      NULL
-   },
-   {
-      MESA_FORMAT_SRGB_DXT1,
-      NULL,
-      _mesa_fetch_texel_2d_f_srgb_dxt1,
-      NULL,
-      NULL
-   },
-   {
-      MESA_FORMAT_SRGBA_DXT1,
-      NULL,
-      _mesa_fetch_texel_2d_f_srgba_dxt1,
-      NULL,
-      NULL
-   },
-   {
-      MESA_FORMAT_SRGBA_DXT3,
-      NULL,
-      _mesa_fetch_texel_2d_f_srgba_dxt3,
-      NULL,
-      NULL
-   },
-   {
-      MESA_FORMAT_SRGBA_DXT5,
-      NULL,
-      _mesa_fetch_texel_2d_f_srgba_dxt5,
-      NULL,
-      NULL
-   },
-   {
-      MESA_FORMAT_RGBA_FLOAT32,
-      fetch_texel_1d_f_rgba_f32,
-      fetch_texel_2d_f_rgba_f32,
-      fetch_texel_3d_f_rgba_f32,
-      store_texel_rgba_f32
-   },
-   {
-      MESA_FORMAT_RGBA_FLOAT16,
-      fetch_texel_1d_f_rgba_f16,
-      fetch_texel_2d_f_rgba_f16,
-      fetch_texel_3d_f_rgba_f16,
-      store_texel_rgba_f16
-   },
-   {
-      MESA_FORMAT_RGB_FLOAT32,
-      fetch_texel_1d_f_rgb_f32,
-      fetch_texel_2d_f_rgb_f32,
-      fetch_texel_3d_f_rgb_f32,
-      store_texel_rgb_f32
-   },
-   {
-      MESA_FORMAT_RGB_FLOAT16,
-      fetch_texel_1d_f_rgb_f16,
-      fetch_texel_2d_f_rgb_f16,
-      fetch_texel_3d_f_rgb_f16,
-      store_texel_rgb_f16
-   },
-   {
-      MESA_FORMAT_ALPHA_FLOAT32,
-      fetch_texel_1d_f_alpha_f32,
-      fetch_texel_2d_f_alpha_f32,
-      fetch_texel_3d_f_alpha_f32,
-      store_texel_alpha_f32
-   },
-   {
-      MESA_FORMAT_ALPHA_FLOAT16,
-      fetch_texel_1d_f_alpha_f16,
-      fetch_texel_2d_f_alpha_f16,
-      fetch_texel_3d_f_alpha_f16,
-      store_texel_alpha_f16
-   },
-   {
-      MESA_FORMAT_LUMINANCE_FLOAT32,
-      fetch_texel_1d_f_luminance_f32,
-      fetch_texel_2d_f_luminance_f32,
-      fetch_texel_3d_f_luminance_f32,
-      store_texel_luminance_f32
-   },
-   {
-      MESA_FORMAT_LUMINANCE_FLOAT16,
-      fetch_texel_1d_f_luminance_f16,
-      fetch_texel_2d_f_luminance_f16,
-      fetch_texel_3d_f_luminance_f16,
-      store_texel_luminance_f16
-   },
-   {
-      MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
-      fetch_texel_1d_f_luminance_alpha_f32,
-      fetch_texel_2d_f_luminance_alpha_f32,
-      fetch_texel_3d_f_luminance_alpha_f32,
-      store_texel_luminance_alpha_f32
-   },
-   {
-      MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
-      fetch_texel_1d_f_luminance_alpha_f16,
-      fetch_texel_2d_f_luminance_alpha_f16,
-      fetch_texel_3d_f_luminance_alpha_f16,
-      store_texel_luminance_alpha_f16
-   },
-   {
-      MESA_FORMAT_INTENSITY_FLOAT32,
-      fetch_texel_1d_f_intensity_f32,
-      fetch_texel_2d_f_intensity_f32,
-      fetch_texel_3d_f_intensity_f32,
-      store_texel_intensity_f32
-   },
-   {
-      MESA_FORMAT_INTENSITY_FLOAT16,
-      fetch_texel_1d_f_intensity_f16,
-      fetch_texel_2d_f_intensity_f16,
-      fetch_texel_3d_f_intensity_f16,
-      store_texel_intensity_f16
-   },
-   {
-      MESA_FORMAT_DUDV8,
-      fetch_texel_1d_dudv8,
-      fetch_texel_2d_dudv8,
-      fetch_texel_3d_dudv8,
-      NULL
-   },
-   {
-      MESA_FORMAT_SIGNED_RGBA8888,
-      fetch_texel_1d_signed_rgba8888,
-      fetch_texel_2d_signed_rgba8888,
-      fetch_texel_3d_signed_rgba8888,
-      store_texel_signed_rgba8888
-   },
-   {
-      MESA_FORMAT_SIGNED_RGBA8888_REV,
-      fetch_texel_1d_signed_rgba8888_rev,
-      fetch_texel_2d_signed_rgba8888_rev,
-      fetch_texel_3d_signed_rgba8888_rev,
-      store_texel_signed_rgba8888_rev
-   },
-   {
-      MESA_FORMAT_RGBA8888,
-      fetch_texel_1d_f_rgba8888,
-      fetch_texel_2d_f_rgba8888,
-      fetch_texel_3d_f_rgba8888,
-      store_texel_rgba8888
-   },
-   {
-      MESA_FORMAT_RGBA8888_REV,
-      fetch_texel_1d_f_rgba8888_rev,
-      fetch_texel_2d_f_rgba8888_rev,
-      fetch_texel_3d_f_rgba8888_rev,
-      store_texel_rgba8888_rev
-   },
-   {
-      MESA_FORMAT_ARGB8888,
-      fetch_texel_1d_f_argb8888,
-      fetch_texel_2d_f_argb8888,
-      fetch_texel_3d_f_argb8888,
-      store_texel_argb8888
-   },
-   {
-      MESA_FORMAT_ARGB8888_REV,
-      fetch_texel_1d_f_argb8888_rev,
-      fetch_texel_2d_f_argb8888_rev,
-      fetch_texel_3d_f_argb8888_rev,
-      store_texel_argb8888_rev
-   },
-   {
-      MESA_FORMAT_RGB888,
-      fetch_texel_1d_f_rgb888,
-      fetch_texel_2d_f_rgb888,
-      fetch_texel_3d_f_rgb888,
-      store_texel_rgb888
-   },
-   {
-      MESA_FORMAT_BGR888,
-      fetch_texel_1d_f_bgr888,
-      fetch_texel_2d_f_bgr888,
-      fetch_texel_3d_f_bgr888,
-      store_texel_bgr888
-   },
-   {
-      MESA_FORMAT_RGB565,
-      fetch_texel_1d_f_rgb565,
-      fetch_texel_2d_f_rgb565,
-      fetch_texel_3d_f_rgb565,
-      store_texel_rgb565
-   },
-   {
-      MESA_FORMAT_RGB565_REV,
-      fetch_texel_1d_f_rgb565_rev,
-      fetch_texel_2d_f_rgb565_rev,
-      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,
-      fetch_texel_2d_f_argb4444,
-      fetch_texel_3d_f_argb4444,
-      store_texel_argb4444
-   },
-   {
-      MESA_FORMAT_ARGB4444_REV,
-      fetch_texel_1d_f_argb4444_rev,
-      fetch_texel_2d_f_argb4444_rev,
-      fetch_texel_3d_f_argb4444_rev,
-      store_texel_argb4444_rev
-   },
-   {
-      MESA_FORMAT_RGBA5551,
-      fetch_texel_1d_f_rgba5551,
-      fetch_texel_2d_f_rgba5551,
-      fetch_texel_3d_f_rgba5551,
-      store_texel_rgba5551
-   },
-   {
-      MESA_FORMAT_ARGB1555,
-      fetch_texel_1d_f_argb1555,
-      fetch_texel_2d_f_argb1555,
-      fetch_texel_3d_f_argb1555,
-      store_texel_argb1555
-   },
-   {
-      MESA_FORMAT_ARGB1555_REV,
-      fetch_texel_1d_f_argb1555_rev,
-      fetch_texel_2d_f_argb1555_rev,
-      fetch_texel_3d_f_argb1555_rev,
-      store_texel_argb1555_rev
-   },
-   {
-      MESA_FORMAT_AL88,
-      fetch_texel_1d_f_al88,
-      fetch_texel_2d_f_al88,
-      fetch_texel_3d_f_al88,
-      store_texel_al88
-   },
-   {
-      MESA_FORMAT_AL88_REV,
-      fetch_texel_1d_f_al88_rev,
-      fetch_texel_2d_f_al88_rev,
-      fetch_texel_3d_f_al88_rev,
-      store_texel_al88_rev
-   },
-   {
-      MESA_FORMAT_RGB332,
-      fetch_texel_1d_f_rgb332,
-      fetch_texel_2d_f_rgb332,
-      fetch_texel_3d_f_rgb332,
-      store_texel_rgb332
-   },
-   {
-      MESA_FORMAT_A8,
-      fetch_texel_1d_f_a8,
-      fetch_texel_2d_f_a8,
-      fetch_texel_3d_f_a8,
-      store_texel_a8
-   },
-   {
-      MESA_FORMAT_L8,
-      fetch_texel_1d_f_l8,
-      fetch_texel_2d_f_l8,
-      fetch_texel_3d_f_l8,
-      store_texel_l8
-   },
-   {
-      MESA_FORMAT_I8,
-      fetch_texel_1d_f_i8,
-      fetch_texel_2d_f_i8,
-      fetch_texel_3d_f_i8,
-      store_texel_i8
-   },
-   {
-      MESA_FORMAT_CI8,
-      fetch_texel_1d_f_ci8,
-      fetch_texel_2d_f_ci8,
-      fetch_texel_3d_f_ci8,
-      store_texel_ci8
-   },
-   {
-      MESA_FORMAT_YCBCR,
-      fetch_texel_1d_f_ycbcr,
-      fetch_texel_2d_f_ycbcr,
-      fetch_texel_3d_f_ycbcr,
-      store_texel_ycbcr
-   },
-   {
-      MESA_FORMAT_YCBCR_REV,
-      fetch_texel_1d_f_ycbcr_rev,
-      fetch_texel_2d_f_ycbcr_rev,
-      fetch_texel_3d_f_ycbcr_rev,
-      store_texel_ycbcr_rev
-   },
-   {
-      MESA_FORMAT_Z24_S8,
-      fetch_texel_1d_f_z24_s8,
-      fetch_texel_2d_f_z24_s8,
-      fetch_texel_3d_f_z24_s8,
-      store_texel_z24_s8
-   },
-   {
-      MESA_FORMAT_S8_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_Z16,
-      fetch_texel_1d_f_z16,
-      fetch_texel_2d_f_z16,
-      fetch_texel_3d_f_z16,
-      store_texel_z16
-   },
-   {
-      MESA_FORMAT_Z32,
-      fetch_texel_1d_f_z32,
-      fetch_texel_2d_f_z32,
-      fetch_texel_3d_f_z32,
-      store_texel_z32
-   }
-};
-
-
-FetchTexelFuncF
-_mesa_get_texel_fetch_func(GLuint format, GLuint dims)
-{
-   FetchTexelFuncF f;
-   GLuint i;
-   /* XXX replace loop with direct table lookup */
-   for (i = 0; i < MESA_FORMAT_COUNT; i++) {
-      if (texfetch_funcs[i].Name == format) {
-         switch (dims) {
-         case 1:
-            f = texfetch_funcs[i].Fetch1D;
-            break;
-         case 2:
-            f = texfetch_funcs[i].Fetch2D;
-            break;
-         case 3:
-            f = texfetch_funcs[i].Fetch3D;
-            break;
-         }
-         if (!f)
-            f = fetch_null_texelf;
-         return f;
-      }
-   }
-   return NULL;
-}
-
-
-StoreTexelFunc
-_mesa_get_texel_store_func(GLuint format)
-{
-   GLuint i;
-   /* XXX replace loop with direct table lookup */
-   for (i = 0; i < MESA_FORMAT_COUNT; i++) {
-      if (texfetch_funcs[i].Name == format) {
-         if (texfetch_funcs[i].StoreTexel)
-            return texfetch_funcs[i].StoreTexel;
-         else
-            return store_null_texel;
-      }
-   }
-   return NULL;
-}
index ed6a3a38511ded77ce913601a6807abfc0e5dcc0..0711b67da139ab6be09a47dcaaf6df5f0fdd7e12 100644 (file)
@@ -1,9 +1,9 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.1
+ * Version:  7.75
  *
- * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
- * Copyright (c) 2008 VMware, Inc.
+ * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
+ * Copyright (c) 2008-2009 VMware, Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  */
 
-
-/**
- * \file texformat.h
- * Texture formats definitions.
- *
- * \author Gareth Hughes
- */
-
-
 #ifndef TEXFORMAT_H
 #define TEXFORMAT_H
 
@@ -49,11 +40,4 @@ extern void
 _mesa_format_to_type_and_comps(gl_format format,
                                GLenum *datatype, GLuint *comps);
 
-extern FetchTexelFuncF
-_mesa_get_texel_fetch_func(GLuint format, GLuint dims);
-
-extern StoreTexelFunc
-_mesa_get_texel_store_func(GLuint format);
-
-
 #endif
index 81bb1d40ffdfed49647a1f6fdbb6b2b6fe72ee5d..f47478421a18772ac0b9e97be80318ad8986d97c 100644 (file)
@@ -1,7 +1,7 @@
 
 #include "context.h"
 #include "fbobject.h"
-#include "texformat.h"
+#include "texfetch.h"
 #include "texrender.h"
 #include "renderbuffer.h"
 
index 02e3df89cf5c0c0399a0f4ea70504bba8c250b99..d5bc16dee41be052020267520bddd7d4282fc422 100644 (file)
@@ -64,6 +64,7 @@
 #include "texcompress.h"
 #include "texcompress_fxt1.h"
 #include "texcompress_s3tc.h"
+#include "texfetch.h"
 #include "texformat.h"
 #include "teximage.h"
 #include "texstore.h"
index dab3e56038671f74a87a11ab638a48104f62bd25..8959ff535627088b2d5321493502ea1cec3333f3 100644 (file)
@@ -68,6 +68,7 @@ MAIN_SOURCES = \
        main/texcompress_fxt1.c \
        main/texenv.c \
        main/texenvprogram.c \
+       main/texfetch.c \
        main/texformat.c \
        main/texgen.c \
        main/texgetimage.c \
index 4d7df7417026034995f98fc50fdc557299760dfd..9a24acf81965bbddc6492ec41e586d80034207b5 100644 (file)
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\texenvprogram.c">\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texfetch.c">\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\texformat.c">\r
                        </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\texenvprogram.h">\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texfetch.h">\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\texformat.h">\r
                        </File>\r
index f15c4435f617b4af5399ef3ea8df41054400ca2c..ec413141954b633a967369308cd699dc505eff6c 100644 (file)
                                RelativePath="..\..\..\..\src\mesa\main\texenvprogram.c"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texfetch.c"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\texformat.c"\r
                                >\r
                                RelativePath="..\..\..\..\src\mesa\main\texenvprogram.h"\r
                                >\r
                        </File>\r
+                       <File\r
+                               RelativePath="..\..\..\..\src\mesa\main\texfetch.h"\r
+                               >\r
+                       </File>\r
                        <File\r
                                RelativePath="..\..\..\..\src\mesa\main\texformat.h"\r
                                >\r