mesa: fix assertion failure for GL_ALPHA FBOs
[mesa.git] / src / mesa / main / texfetch_tmp.h
index e6772c89f36ae17f5dfbc036d9da1a0d9b1d7aa2..e51fe3a577306e4eba173c0a1fc4a5ad06ea6a09 100644 (file)
@@ -1209,16 +1209,86 @@ static void FETCH(dudv8)(const struct gl_texture_image *texImage,
    texel[ACOMP] = 0;
 }
 
+
+/* MESA_FORMAT_SIGNED_R8 ***********************************************/
+
+static void FETCH(signed_r8)( const struct gl_texture_image *texImage,
+                              GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLbyte s = *TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+   texel[RCOMP] = BYTE_TO_FLOAT_TEX( s );
+   texel[GCOMP] = 0.0F;
+   texel[BCOMP] = 0.0F;
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_signed_r8(struct gl_texture_image *texImage,
+                                  GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLbyte *rgba = (const GLbyte *) texel;
+   GLbyte *dst = TEXEL_ADDR(GLbyte, texImage, i, j, k, 1);
+   *dst = rgba[RCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RG88 ***********************************************/
+
+static void FETCH(signed_rg88)( const struct gl_texture_image *texImage,
+                                GLint i, GLint j, GLint k, GLfloat *texel )
+{
+   const GLushort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+   texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 8) );
+   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s & 0xff) );
+   texel[BCOMP] = 0.0F;
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void store_texel_signed_rg88(struct gl_texture_image *texImage,
+                                    GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLbyte *rg = (const GLbyte *) texel;
+   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 2);
+   *dst = PACK_COLOR_88(rg[RCOMP], rg[GCOMP]);
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RGBX8888 ***********************************************/
+
+static void FETCH(signed_rgbx8888)( 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] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
+   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
+   texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >>  8) );
+   texel[ACOMP] = 1.0f;
+}
+
+#if DIM == 3
+static void store_texel_signed_rgbx8888(struct gl_texture_image *texImage,
+                                        GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLbyte *rgba = (const GLbyte *) texel;
+   GLuint *dst = TEXEL_ADDR(GLuint, texImage, i, j, k, 1);
+   *dst = PACK_COLOR_8888(rgba[RCOMP], rgba[GCOMP], rgba[BCOMP], 255);
+}
+#endif
+
+
 /* MESA_FORMAT_SIGNED_RGBA8888 ***********************************************/
 
 static void FETCH(signed_rgba8888)( 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] = BYTE_TO_FLOAT_TEX( (s >> 24)        );
-   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (s >> 16) & 0xff );
-   texel[BCOMP] = BYTE_TO_FLOAT_TEX( (s >>  8) & 0xff );
-   texel[ACOMP] = BYTE_TO_FLOAT_TEX( (s      ) & 0xff );
+   texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
+   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
+   texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >>  8) );
+   texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s      ) );
 }
 
 #if DIM == 3
@@ -1235,10 +1305,10 @@ static void FETCH(signed_rgba8888_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] = BYTE_TO_FLOAT_TEX( (s      ) & 0xff );
-   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (s >>  8) & 0xff );
-   texel[BCOMP] = BYTE_TO_FLOAT_TEX( (s >> 16) & 0xff );
-   texel[ACOMP] = BYTE_TO_FLOAT_TEX( (s >> 24)        );
+   texel[RCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s      ) );
+   texel[GCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >>  8) );
+   texel[BCOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 16) );
+   texel[ACOMP] = BYTE_TO_FLOAT_TEX( (GLbyte) (s >> 24) );
 }
 
 #if DIM == 3
@@ -1253,6 +1323,142 @@ static void store_texel_signed_rgba8888_rev(struct gl_texture_image *texImage,
 
 
 
+/* MESA_FORMAT_SIGNED_R_16 ***********************************************/
+
+static void
+FETCH(signed_r_16)(const struct gl_texture_image *texImage,
+                   GLint i, GLint j, GLint k, GLfloat *texel)
+{
+   const GLshort s = *TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+   texel[RCOMP] = SHORT_TO_FLOAT_TEX( s );
+   texel[GCOMP] = 0.0F;
+   texel[BCOMP] = 0.0F;
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void
+store_texel_signed_r_16(struct gl_texture_image *texImage,
+                        GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLshort *rgba = (const GLshort *) texel;
+   GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 1);
+   *dst = rgba[0];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RG_16 ***********************************************/
+
+static void
+FETCH(signed_rg_16)(const struct gl_texture_image *texImage,
+                    GLint i, GLint j, GLint k, GLfloat *texel)
+{
+   const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
+   texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
+   texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
+   texel[BCOMP] = 0.0F;
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void
+store_texel_signed_rg_16(struct gl_texture_image *texImage,
+                         GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLshort *rgba = (const GLshort *) texel;
+   GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 2);
+   dst[0] = rgba[RCOMP];
+   dst[1] = rgba[GCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/
+
+static void 
+FETCH(signed_rgb_16)(const struct gl_texture_image *texImage,
+                     GLint i, GLint j, GLint k, GLfloat *texel)
+{
+   const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 3);
+   texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
+   texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
+   texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] );
+   texel[ACOMP] = 1.0F;
+}
+
+#if DIM == 3
+static void
+store_texel_signed_rgb_16(struct gl_texture_image *texImage,
+                          GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLshort *rgba = (const GLshort *) texel;
+   GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 3);
+   dst[0] = rgba[RCOMP];
+   dst[1] = rgba[GCOMP];
+   dst[2] = rgba[BCOMP];
+}
+#endif
+
+
+/* MESA_FORMAT_SIGNED_RGBA_16 ***********************************************/
+
+static void
+FETCH(signed_rgba_16)(const struct gl_texture_image *texImage,
+                      GLint i, GLint j, GLint k, GLfloat *texel)
+{
+   const GLshort *s = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
+   texel[RCOMP] = SHORT_TO_FLOAT_TEX( s[0] );
+   texel[GCOMP] = SHORT_TO_FLOAT_TEX( s[1] );
+   texel[BCOMP] = SHORT_TO_FLOAT_TEX( s[2] );
+   texel[ACOMP] = SHORT_TO_FLOAT_TEX( s[3] );
+}
+
+#if DIM == 3
+static void
+store_texel_signed_rgba_16(struct gl_texture_image *texImage,
+                           GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLshort *rgba = (const GLshort *) texel;
+   GLshort *dst = TEXEL_ADDR(GLshort, texImage, i, j, k, 4);
+   dst[0] = rgba[RCOMP];
+   dst[1] = rgba[GCOMP];
+   dst[2] = rgba[BCOMP];
+   dst[3] = rgba[ACOMP];
+}
+#endif
+
+
+
+/* MESA_FORMAT_RGBA_16 ***********************************************/
+
+static void
+FETCH(rgba_16)(const struct gl_texture_image *texImage,
+               GLint i, GLint j, GLint k, GLfloat *texel)
+{
+   const GLushort *s = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
+   texel[RCOMP] = USHORT_TO_FLOAT( s[0] );
+   texel[GCOMP] = USHORT_TO_FLOAT( s[1] );
+   texel[BCOMP] = USHORT_TO_FLOAT( s[2] );
+   texel[ACOMP] = USHORT_TO_FLOAT( s[3] );
+}
+
+#if DIM == 3
+static void
+store_texel_rgba_16(struct gl_texture_image *texImage,
+                    GLint i, GLint j, GLint k, const void *texel)
+{
+   const GLushort *rgba = (const GLushort *) texel;
+   GLushort *dst = TEXEL_ADDR(GLushort, texImage, i, j, k, 4);
+   dst[0] = rgba[RCOMP];
+   dst[1] = rgba[GCOMP];
+   dst[2] = rgba[BCOMP];
+   dst[3] = rgba[ACOMP];
+}
+#endif
+
+
+
 /* MESA_FORMAT_YCBCR *********************************************************/
 
 /* Fetch texel from 1D, 2D or 3D ycbcr texture, return 4 GLfloats.