AL1616: Add texel fetch / store routines
authorIan Romanick <ian.d.romanick@intel.com>
Mon, 16 Nov 2009 22:52:43 +0000 (14:52 -0800)
committerIan Romanick <ian.d.romanick@intel.com>
Mon, 16 Nov 2009 23:23:16 +0000 (15:23 -0800)
src/mesa/main/texfetch.c
src/mesa/main/texfetch_tmp.h

index 314ccb7b65fe446810370d5d76317bd6d0823ff8..c431d3a1db59213a35d04b3cfe59eaac50ad6836 100644 (file)
@@ -452,6 +452,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,
index 27434946ec830730989a94d813cbcda979cb1685..093e0abc49519a235c2339f49a673642ddb81f8b 100644 (file)
@@ -834,6 +834,54 @@ static void store_texel_al88_rev(struct gl_texture_image *texImage,
 #endif
 
 
+/* MESA_FORMAT_AL1616 ********************************************************/
+
+/* Fetch texel from 1D, 2D or 3D al1616 texture, return 4 GLchans */
+static void FETCH(f_al1616)( const struct gl_texture_image *texImage,
+                            GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint s = *TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = USHORT_TO_FLOAT( s & 0xffff );
+   texel[ACOMP] = USHORT_TO_FLOAT( s >> 16 );
+}
+
+#if DIM == 3
+static void store_texel_al1616(struct gl_texture_image *texImage,
+                             GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLushort *rgba = (const GLushort *) texel;
+   GLuint *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_1616(rgba[ACOMP], rgba[RCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_AL1616_REV ****************************************************/
+
+/* Fetch texel from 1D, 2D or 3D al1616_rev texture, return 4 GLchans */
+static void FETCH(f_al1616_rev)( const struct gl_texture_image *texImage,
+                                GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLuint s = *TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   texel[RCOMP] =
+   texel[GCOMP] =
+   texel[BCOMP] = USHORT_TO_FLOAT( s >> 16 );
+   texel[ACOMP] = USHORT_TO_FLOAT( s & 0xffff );
+}
+
+#if DIM == 3
+static void store_texel_al1616_rev(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLushort *rgba = (const GLushort *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_1616(rgba[RCOMP], rgba[ACOMP]);
+}
+#endif
+
+
 /* MESA_FORMAT_RGB332 ********************************************************/
 
 /* Fetch texel from 1D, 2D or 3D rgb332 texture, return 4 GLchans */