swrast: Add support for fetching from MESA_FORMAT_R10G10B10A2_UNORM
authorChris Forbes <chrisf@ijw.co.nz>
Sat, 29 Mar 2014 04:29:37 +0000 (17:29 +1300)
committerChris Forbes <chrisf@ijw.co.nz>
Thu, 10 Apr 2014 06:27:40 +0000 (18:27 +1200)
V4: Fix rebase conflicts with Brian's renaming of the texfetch
functions.

Signed-off-by: Chris Forbes <chrisf@ijw.co.nz>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Brian Paul <brianp@vmware.com>
Acked-by: Eric Anholt <eric@anholt.net>
src/mesa/swrast/s_texfetch.c
src/mesa/swrast/s_texfetch_tmp.h

index 3ad4a5b86c610577f41d5b17f2a9d28cb283a760..098a32fd4beb3866d13732b593563ac4eac1c93c 100644 (file)
@@ -325,9 +325,9 @@ texfetch_funcs[] =
    },
    {
       MESA_FORMAT_R10G10B10A2_UNORM,
-      NULL,
-      NULL,
-      NULL
+      fetch_texel_1d_R10G10B10A2_UNORM,
+      fetch_texel_2d_R10G10B10A2_UNORM,
+      fetch_texel_3d_R10G10B10A2_UNORM
    },
    {
       MESA_FORMAT_S8_UINT_Z24_UNORM,
index b1981e4d332f16a53e403fca0f358f22966ea9d7..c783ae34f1ce830cad26f546b7963440237ee16e 100644 (file)
@@ -502,6 +502,19 @@ FETCH(B10G10R10A2_UNORM)(const struct swrast_texture_image *texImage,
 }
 
 
+static void
+FETCH(R10G10B10A2_UNORM)(const struct swrast_texture_image *texImage,
+                         GLint i, GLint j, GLint k, GLfloat *texel)
+{
+   const GLuint *src = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   const GLuint s = *src;
+   texel[RCOMP] = ((s >>  0) & 0x3ff) * (1.0F / 1023.0F);
+   texel[GCOMP] = ((s >> 10) & 0x3ff) * (1.0F / 1023.0F);
+   texel[BCOMP] = ((s >> 20) & 0x3ff) * (1.0F / 1023.0F);
+   texel[ACOMP] = ((s >> 30) & 0x03) * (1.0F / 3.0F);
+}
+
+
 static void
 FETCH(R8G8_UNORM)(const struct swrast_texture_image *texImage,
                   GLint i, GLint j, GLint k, GLfloat *texel)