aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-03-10 12:57:09 +0000
committermarha <marha@users.sourceforge.net>2011-03-10 12:57:09 +0000
commitae312a8a8042b4b23ffc652acf3b5cad1b3f07ca (patch)
treef54be422d872ddfcc3fa96dafe8c40288548ef22 /mesalib/src/mesa/main
parentb5f8cc93800ce69d2c984081471b05e650ba9ddd (diff)
parentf81bb3160c5f39d8f7ad329e99865af88f02b96a (diff)
downloadvcxsrv-ae312a8a8042b4b23ffc652acf3b5cad1b3f07ca.tar.gz
vcxsrv-ae312a8a8042b4b23ffc652acf3b5cad1b3f07ca.tar.bz2
vcxsrv-ae312a8a8042b4b23ffc652acf3b5cad1b3f07ca.zip
svn merge ^/branches/released .
Diffstat (limited to 'mesalib/src/mesa/main')
-rw-r--r--mesalib/src/mesa/main/extensions.c4
-rw-r--r--mesalib/src/mesa/main/formats.c40
-rw-r--r--mesalib/src/mesa/main/formats.h8
-rw-r--r--mesalib/src/mesa/main/glheader.h4
-rw-r--r--mesalib/src/mesa/main/image.c12
-rw-r--r--mesalib/src/mesa/main/mipmap.c9
-rw-r--r--mesalib/src/mesa/main/mtypes.h2
-rw-r--r--mesalib/src/mesa/main/texcompress.c19
-rw-r--r--mesalib/src/mesa/main/texcompress_rgtc.c68
-rw-r--r--mesalib/src/mesa/main/texcompress_rgtc.h137
-rw-r--r--mesalib/src/mesa/main/texfetch.c28
-rw-r--r--mesalib/src/mesa/main/texformat.c29
-rw-r--r--mesalib/src/mesa/main/teximage.c22
-rw-r--r--mesalib/src/mesa/main/texstore.c9
14 files changed, 324 insertions, 67 deletions
diff --git a/mesalib/src/mesa/main/extensions.c b/mesalib/src/mesa/main/extensions.c
index a4aa9847a..6de0ca696 100644
--- a/mesalib/src/mesa/main/extensions.c
+++ b/mesalib/src/mesa/main/extensions.c
@@ -181,6 +181,7 @@ static const struct extension extension_table[] = {
{ "GL_EXT_texture3D", o(EXT_texture3D), GL },
{ "GL_EXT_texture_array", o(EXT_texture_array), GL },
{ "GL_EXT_texture_compression_dxt1", o(EXT_texture_compression_s3tc), GL | ES1 | ES2 },
+ { "GL_EXT_texture_compression_latc", o(EXT_texture_compression_latc), GL },
{ "GL_EXT_texture_compression_rgtc", o(ARB_texture_compression_rgtc), GL },
{ "GL_EXT_texture_compression_s3tc", o(EXT_texture_compression_s3tc), GL },
{ "GL_EXT_texture_cube_map", o(ARB_texture_cube_map), GL },
@@ -258,6 +259,7 @@ static const struct extension extension_table[] = {
{ "GL_ATI_envmap_bumpmap", o(ATI_envmap_bumpmap), GL },
{ "GL_ATI_fragment_shader", o(ATI_fragment_shader), GL },
{ "GL_ATI_separate_stencil", o(ATI_separate_stencil), GL },
+ { "GL_ATI_texture_compression_3dc", o(ATI_texture_compression_3dc), GL },
{ "GL_ATI_texture_env_combine3", o(ATI_texture_env_combine3), GL },
{ "GL_ATI_texture_mirror_once", o(ATI_texture_mirror_once), GL },
{ "GL_IBM_multimode_draw_arrays", o(IBM_multimode_draw_arrays), GL },
@@ -448,6 +450,7 @@ _mesa_enable_sw_extensions(struct gl_context *ctx)
#if FEATURE_ATI_fragment_shader
ctx->Extensions.ATI_fragment_shader = GL_TRUE;
#endif
+ ctx->Extensions.ATI_texture_compression_3dc = GL_TRUE;
ctx->Extensions.ATI_texture_env_combine3 = GL_TRUE;
ctx->Extensions.ATI_texture_mirror_once = GL_TRUE;
ctx->Extensions.ATI_separate_stencil = GL_TRUE;
@@ -483,6 +486,7 @@ _mesa_enable_sw_extensions(struct gl_context *ctx)
ctx->Extensions.EXT_stencil_wrap = GL_TRUE;
ctx->Extensions.EXT_stencil_two_side = GL_TRUE;
ctx->Extensions.EXT_texture_array = GL_TRUE;
+ ctx->Extensions.EXT_texture_compression_latc = GL_TRUE;
ctx->Extensions.EXT_texture_env_add = GL_TRUE;
ctx->Extensions.EXT_texture_env_combine = GL_TRUE;
ctx->Extensions.EXT_texture_env_dot3 = GL_TRUE;
diff --git a/mesalib/src/mesa/main/formats.c b/mesalib/src/mesa/main/formats.c
index 1d7bdad24..e2541bdf6 100644
--- a/mesalib/src/mesa/main/formats.c
+++ b/mesalib/src/mesa/main/formats.c
@@ -927,6 +927,42 @@ static struct gl_format_info format_info[MESA_FORMAT_COUNT] =
0, 0, 0, 0, 0,
4, 4, 16 /* 16 bytes per 4x4 block */
},
+ {
+ MESA_FORMAT_L_LATC1,
+ "MESA_FORMAT_L_LATC1",
+ GL_LUMINANCE,
+ GL_UNSIGNED_NORMALIZED,
+ 0, 0, 0, 0,
+ 4, 0, 0, 0, 0,
+ 4, 4, 8 /* 8 bytes per 4x4 block */
+ },
+ {
+ MESA_FORMAT_SIGNED_L_LATC1,
+ "MESA_FORMAT_SIGNED_L_LATC1",
+ GL_LUMINANCE,
+ GL_SIGNED_NORMALIZED,
+ 0, 0, 0, 0,
+ 4, 0, 0, 0, 0,
+ 4, 4, 8 /* 8 bytes per 4x4 block */
+ },
+ {
+ MESA_FORMAT_LA_LATC2,
+ "MESA_FORMAT_LA_LATC2",
+ GL_LUMINANCE_ALPHA,
+ GL_UNSIGNED_NORMALIZED,
+ 0, 0, 0, 4,
+ 4, 0, 0, 0, 0,
+ 4, 4, 16 /* 16 bytes per 4x4 block */
+ },
+ {
+ MESA_FORMAT_SIGNED_LA_LATC2,
+ "MESA_FORMAT_SIGNED_LA_LATC2",
+ GL_LUMINANCE_ALPHA,
+ GL_SIGNED_NORMALIZED,
+ 0, 0, 0, 4,
+ 4, 0, 0, 0, 0,
+ 4, 4, 16 /* 16 bytes per 4x4 block */
+ },
};
@@ -1570,6 +1606,10 @@ _mesa_format_to_type_and_comps(gl_format format,
case MESA_FORMAT_SIGNED_RED_RGTC1:
case MESA_FORMAT_RG_RGTC2:
case MESA_FORMAT_SIGNED_RG_RGTC2:
+ case MESA_FORMAT_L_LATC1:
+ case MESA_FORMAT_SIGNED_L_LATC1:
+ case MESA_FORMAT_LA_LATC2:
+ case MESA_FORMAT_SIGNED_LA_LATC2:
/* XXX generate error instead? */
*datatype = GL_UNSIGNED_BYTE;
*comps = 0;
diff --git a/mesalib/src/mesa/main/formats.h b/mesalib/src/mesa/main/formats.h
index b32829145..81ba76ce0 100644
--- a/mesalib/src/mesa/main/formats.h
+++ b/mesalib/src/mesa/main/formats.h
@@ -185,6 +185,14 @@ typedef enum
MESA_FORMAT_RG_RGTC2,
MESA_FORMAT_SIGNED_RG_RGTC2,
/*@}*/
+
+ /*@{*/
+ MESA_FORMAT_L_LATC1,
+ MESA_FORMAT_SIGNED_L_LATC1,
+ MESA_FORMAT_LA_LATC2,
+ MESA_FORMAT_SIGNED_LA_LATC2,
+ /*@}*/
+
MESA_FORMAT_COUNT
} gl_format;
diff --git a/mesalib/src/mesa/main/glheader.h b/mesalib/src/mesa/main/glheader.h
index 5ca44deb0..dc78ccbf6 100644
--- a/mesalib/src/mesa/main/glheader.h
+++ b/mesalib/src/mesa/main/glheader.h
@@ -121,6 +121,10 @@ typedef void *GLeglImageOES;
#define GL_MAX_FRAGMENT_UNIFORM_VECTORS 0x8DFD
#endif
+#ifndef GL_ATI_texture_compression_3dc
+#define GL_ATI_texture_compression_3dc 1
+#define GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI 0x8837
+#endif
/**
diff --git a/mesalib/src/mesa/main/image.c b/mesalib/src/mesa/main/image.c
index 444f21ed5..466fc617a 100644
--- a/mesalib/src/mesa/main/image.c
+++ b/mesalib/src/mesa/main/image.c
@@ -743,6 +743,11 @@ _mesa_is_color_format(GLenum format)
case GL_COMPRESSED_SIGNED_RED_RGTC1:
case GL_COMPRESSED_RG_RGTC2:
case GL_COMPRESSED_SIGNED_RG_RGTC2:
+ case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
+ case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
+ case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
+ case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
+ case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
/* signed, normalized texture formats */
case GL_RGBA_SNORM:
case GL_RGBA8_SNORM:
@@ -1025,6 +1030,13 @@ _mesa_is_compressed_format(struct gl_context *ctx, GLenum format)
case GL_COMPRESSED_RG_RGTC2:
case GL_COMPRESSED_SIGNED_RG_RGTC2:
return ctx->Extensions.ARB_texture_compression_rgtc;
+ case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
+ case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
+ case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
+ case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
+ return ctx->Extensions.EXT_texture_compression_latc;
+ case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
+ return ctx->Extensions.ATI_texture_compression_3dc;
default:
return GL_FALSE;
}
diff --git a/mesalib/src/mesa/main/mipmap.c b/mesalib/src/mesa/main/mipmap.c
index 453d7f29b..b12399ee6 100644
--- a/mesalib/src/mesa/main/mipmap.c
+++ b/mesalib/src/mesa/main/mipmap.c
@@ -1764,8 +1764,13 @@ _mesa_generate_mipmap(struct gl_context *ctx, GLenum target,
} else if (srcImage->_BaseFormat == GL_RGBA) {
convertFormat = MESA_FORMAT_RGBA8888;
components = 4;
- }
- else {
+ } else if (srcImage->_BaseFormat == GL_LUMINANCE) {
+ convertFormat = MESA_FORMAT_L8;
+ components = 1;
+ } else if (srcImage->_BaseFormat == GL_LUMINANCE_ALPHA) {
+ convertFormat = MESA_FORMAT_AL88;
+ components = 2;
+ } else {
_mesa_problem(ctx, "bad srcImage->_BaseFormat in _mesa_generate_mipmaps");
return;
}
diff --git a/mesalib/src/mesa/main/mtypes.h b/mesalib/src/mesa/main/mtypes.h
index 2862f88da..4e530a268 100644
--- a/mesalib/src/mesa/main/mtypes.h
+++ b/mesalib/src/mesa/main/mtypes.h
@@ -2802,6 +2802,7 @@ struct gl_extensions
GLboolean EXT_texture_object;
GLboolean EXT_texture3D;
GLboolean EXT_texture_array;
+ GLboolean EXT_texture_compression_latc;
GLboolean EXT_texture_compression_s3tc;
GLboolean EXT_texture_env_add;
GLboolean EXT_texture_env_combine;
@@ -2827,6 +2828,7 @@ struct gl_extensions
GLboolean APPLE_vertex_array_object;
GLboolean APPLE_object_purgeable;
GLboolean ATI_envmap_bumpmap;
+ GLboolean ATI_texture_compression_3dc;
GLboolean ATI_texture_mirror_once;
GLboolean ATI_texture_env_combine3;
GLboolean ATI_fragment_shader;
diff --git a/mesalib/src/mesa/main/texcompress.c b/mesalib/src/mesa/main/texcompress.c
index 9891946df..59603e81e 100644
--- a/mesalib/src/mesa/main/texcompress.c
+++ b/mesalib/src/mesa/main/texcompress.c
@@ -173,6 +173,16 @@ _mesa_glenum_to_compressed_format(GLenum format)
case GL_COMPRESSED_SIGNED_RG_RGTC2:
return MESA_FORMAT_SIGNED_RG_RGTC2;
+ case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
+ return MESA_FORMAT_L_LATC1;
+ case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
+ return MESA_FORMAT_SIGNED_L_LATC1;
+ case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
+ case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
+ return MESA_FORMAT_LA_LATC2;
+ case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
+ return MESA_FORMAT_SIGNED_LA_LATC2;
+
default:
return MESA_FORMAT_NONE;
}
@@ -229,6 +239,15 @@ _mesa_compressed_format_to_glenum(struct gl_context *ctx, GLuint mesaFormat)
case MESA_FORMAT_SIGNED_RG_RGTC2:
return GL_COMPRESSED_SIGNED_RG_RGTC2;
+ case MESA_FORMAT_L_LATC1:
+ return GL_COMPRESSED_LUMINANCE_LATC1_EXT;
+ case MESA_FORMAT_SIGNED_L_LATC1:
+ return GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT;
+ case MESA_FORMAT_LA_LATC2:
+ return GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT;
+ case MESA_FORMAT_SIGNED_LA_LATC2:
+ return GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT;
+
default:
_mesa_problem(ctx, "Unexpected mesa texture format in"
" _mesa_compressed_format_to_glenum()");
diff --git a/mesalib/src/mesa/main/texcompress_rgtc.c b/mesalib/src/mesa/main/texcompress_rgtc.c
index b5dd56dce..60146d09b 100644
--- a/mesalib/src/mesa/main/texcompress_rgtc.c
+++ b/mesalib/src/mesa/main/texcompress_rgtc.c
@@ -98,7 +98,8 @@ _mesa_texstore_red_rgtc1(TEXSTORE_PARAMS)
GLubyte srcpixels[4][4];
GLubyte *blkaddr;
GLint dstRowDiff;
- ASSERT(dstFormat == MESA_FORMAT_RED_RGTC1);
+ ASSERT(dstFormat == MESA_FORMAT_RED_RGTC1 ||
+ dstFormat == MESA_FORMAT_L_LATC1);
ASSERT(dstXoffset % 4 == 0);
ASSERT(dstYoffset % 4 == 0);
ASSERT(dstZoffset % 4 == 0);
@@ -153,7 +154,8 @@ _mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS)
GLbyte srcpixels[4][4];
GLbyte *blkaddr;
GLint dstRowDiff;
- ASSERT(dstFormat == MESA_FORMAT_SIGNED_RED_RGTC1);
+ ASSERT(dstFormat == MESA_FORMAT_SIGNED_RED_RGTC1 ||
+ dstFormat == MESA_FORMAT_SIGNED_L_LATC1);
ASSERT(dstXoffset % 4 == 0);
ASSERT(dstYoffset % 4 == 0);
ASSERT(dstZoffset % 4 == 0);
@@ -208,7 +210,8 @@ _mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS)
GLubyte *blkaddr;
GLint dstRowDiff;
- ASSERT(dstFormat == MESA_FORMAT_RG_RGTC2);
+ ASSERT(dstFormat == MESA_FORMAT_RG_RGTC2 ||
+ dstFormat == MESA_FORMAT_LA_LATC2);
ASSERT(dstXoffset % 4 == 0);
ASSERT(dstYoffset % 4 == 0);
ASSERT(dstZoffset % 4 == 0);
@@ -269,7 +272,8 @@ _mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS)
GLbyte *blkaddr;
GLint dstRowDiff;
- ASSERT(dstFormat == MESA_FORMAT_SIGNED_RG_RGTC2);
+ ASSERT(dstFormat == MESA_FORMAT_SIGNED_RG_RGTC2 ||
+ dstFormat == MESA_FORMAT_SIGNED_LA_LATC2);
ASSERT(dstXoffset % 4 == 0);
ASSERT(dstYoffset % 4 == 0);
ASSERT(dstZoffset % 4 == 0);
@@ -374,6 +378,62 @@ _mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct gl_texture_image *texImage,
texel[ACOMP] = 1.0;
}
+void
+_mesa_fetch_texel_2d_f_l_latc1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ GLubyte red;
+ unsigned_fetch_texel_rgtc(texImage->RowStride, (GLubyte *)(texImage->Data),
+ i, j, &red, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_FLOAT(red);
+ texel[ACOMP] = 1.0;
+}
+
+void
+_mesa_fetch_texel_2d_f_signed_l_latc1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ GLbyte red;
+ signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data),
+ i, j, &red, 1);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = BYTE_TO_FLOAT_TEX(red);
+ texel[ACOMP] = 1.0;
+}
+
+void
+_mesa_fetch_texel_2d_f_la_latc2(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ GLubyte red, green;
+ unsigned_fetch_texel_rgtc(texImage->RowStride, (GLubyte *)(texImage->Data),
+ i, j, &red, 2);
+ unsigned_fetch_texel_rgtc(texImage->RowStride, (GLubyte *)(texImage->Data) + 8,
+ i, j, &green, 2);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = UBYTE_TO_FLOAT(red);
+ texel[ACOMP] = UBYTE_TO_FLOAT(green);
+}
+
+void
+_mesa_fetch_texel_2d_f_signed_la_latc2(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel)
+{
+ GLbyte red, green;
+ signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data),
+ i, j, &red, 2);
+ signed_fetch_texel_rgtc(texImage->RowStride, (GLbyte *)(texImage->Data) + 8,
+ i, j, &green, 2);
+ texel[RCOMP] =
+ texel[GCOMP] =
+ texel[BCOMP] = BYTE_TO_FLOAT_TEX(red);
+ texel[ACOMP] = BYTE_TO_FLOAT_TEX(green);
+}
+
#define TAG(x) unsigned_##x
#define TYPE GLubyte
diff --git a/mesalib/src/mesa/main/texcompress_rgtc.h b/mesalib/src/mesa/main/texcompress_rgtc.h
index 424edc458..a64ef9968 100644
--- a/mesalib/src/mesa/main/texcompress_rgtc.h
+++ b/mesalib/src/mesa/main/texcompress_rgtc.h
@@ -1,60 +1,77 @@
-/*
- * Copyright (C) 2011 Red Hat 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 (including the next
- * paragraph) 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
- * THE AUTHORS OR COPYRIGHT HOLDERS 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 TEXCOMPRESS_RGTC_H
-#define TEXCOMPRESS_RGTC_H
-
-#include "glheader.h"
-#include "mfeatures.h"
-#include "texstore.h"
-
-struct gl_texture_image;
-
-extern GLboolean
-_mesa_texstore_red_rgtc1(TEXSTORE_PARAMS);
-
-extern GLboolean
-_mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS);
-
-extern GLboolean
-_mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS);
-
-extern GLboolean
-_mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS);
-
-extern void
-_mesa_fetch_texel_2d_f_red_rgtc1(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_2d_f_rg_rgtc2(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-
-extern void
-_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct gl_texture_image *texImage,
- GLint i, GLint j, GLint k, GLfloat *texel);
-#endif
+/*
+ * Copyright (C) 2011 Red Hat 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 (including the next
+ * paragraph) 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
+ * THE AUTHORS OR COPYRIGHT HOLDERS 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 TEXCOMPRESS_RGTC_H
+#define TEXCOMPRESS_RGTC_H
+
+#include "glheader.h"
+#include "mfeatures.h"
+#include "texstore.h"
+
+struct gl_texture_image;
+
+extern GLboolean
+_mesa_texstore_red_rgtc1(TEXSTORE_PARAMS);
+
+extern GLboolean
+_mesa_texstore_signed_red_rgtc1(TEXSTORE_PARAMS);
+
+extern GLboolean
+_mesa_texstore_rg_rgtc2(TEXSTORE_PARAMS);
+
+extern GLboolean
+_mesa_texstore_signed_rg_rgtc2(TEXSTORE_PARAMS);
+
+extern void
+_mesa_fetch_texel_2d_f_red_rgtc1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_signed_red_rgtc1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_rg_rgtc2(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_signed_rg_rgtc2(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_l_latc1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_signed_l_latc1(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_la_latc2(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+extern void
+_mesa_fetch_texel_2d_f_signed_la_latc2(const struct gl_texture_image *texImage,
+ GLint i, GLint j, GLint k, GLfloat *texel);
+
+#endif
diff --git a/mesalib/src/mesa/main/texfetch.c b/mesalib/src/mesa/main/texfetch.c
index 8666076ab..33f8dbba2 100644
--- a/mesalib/src/mesa/main/texfetch.c
+++ b/mesalib/src/mesa/main/texfetch.c
@@ -786,6 +786,34 @@ texfetch_funcs[MESA_FORMAT_COUNT] =
NULL,
NULL
},
+ {
+ MESA_FORMAT_L_LATC1,
+ NULL,
+ _mesa_fetch_texel_2d_f_l_latc1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_SIGNED_L_LATC1,
+ NULL,
+ _mesa_fetch_texel_2d_f_signed_l_latc1,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_LA_LATC2,
+ NULL,
+ _mesa_fetch_texel_2d_f_la_latc2,
+ NULL,
+ NULL
+ },
+ {
+ MESA_FORMAT_SIGNED_LA_LATC2,
+ NULL,
+ _mesa_fetch_texel_2d_f_signed_la_latc2,
+ NULL,
+ NULL
+ },
};
diff --git a/mesalib/src/mesa/main/texformat.c b/mesalib/src/mesa/main/texformat.c
index 8040fac7d..80518200b 100644
--- a/mesalib/src/mesa/main/texformat.c
+++ b/mesalib/src/mesa/main/texformat.c
@@ -621,6 +621,35 @@ _mesa_choose_tex_format( struct gl_context *ctx, GLint internalFormat,
}
}
+ if (ctx->Extensions.EXT_texture_compression_latc) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_L_LATC1);
+ break;
+ case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_L_LATC1);
+ break;
+ case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_LA_LATC2);
+ break;
+ case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_SIGNED_LA_LATC2);
+ break;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.ATI_texture_compression_3dc) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
+ RETURN_IF_SUPPORTED(MESA_FORMAT_LA_LATC2);
+ break;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
_mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
return MESA_FORMAT_NONE;
}
diff --git a/mesalib/src/mesa/main/teximage.c b/mesalib/src/mesa/main/teximage.c
index 164dcba5f..f4d7a4212 100644
--- a/mesalib/src/mesa/main/teximage.c
+++ b/mesalib/src/mesa/main/teximage.c
@@ -509,6 +509,28 @@ _mesa_base_tex_format( struct gl_context *ctx, GLint internalFormat )
}
}
+ if (ctx->Extensions.EXT_texture_compression_latc) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_LUMINANCE_LATC1_EXT:
+ case GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT:
+ return GL_LUMINANCE;
+ case GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT:
+ case GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT:
+ return GL_LUMINANCE_ALPHA;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
+ if (ctx->Extensions.ATI_texture_compression_3dc) {
+ switch (internalFormat) {
+ case GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI:
+ return GL_LUMINANCE_ALPHA;
+ default:
+ ; /* fallthrough */
+ }
+ }
+
return -1; /* error */
}
diff --git a/mesalib/src/mesa/main/texstore.c b/mesalib/src/mesa/main/texstore.c
index d091311c1..749956a1f 100644
--- a/mesalib/src/mesa/main/texstore.c
+++ b/mesalib/src/mesa/main/texstore.c
@@ -4135,7 +4135,14 @@ texstore_funcs[MESA_FORMAT_COUNT] =
{ MESA_FORMAT_RED_RGTC1, _mesa_texstore_red_rgtc1 },
{ MESA_FORMAT_SIGNED_RED_RGTC1, _mesa_texstore_signed_red_rgtc1 },
{ MESA_FORMAT_RG_RGTC2, _mesa_texstore_rg_rgtc2 },
- { MESA_FORMAT_SIGNED_RG_RGTC2, _mesa_texstore_signed_rg_rgtc2 }
+ { MESA_FORMAT_SIGNED_RG_RGTC2, _mesa_texstore_signed_rg_rgtc2 },
+
+ /* Re-use the R/RG texstore functions.
+ * The code is generic enough to handle LATC too. */
+ { MESA_FORMAT_L_LATC1, _mesa_texstore_red_rgtc1 },
+ { MESA_FORMAT_SIGNED_L_LATC1, _mesa_texstore_signed_red_rgtc1 },
+ { MESA_FORMAT_LA_LATC2, _mesa_texstore_rg_rgtc2 },
+ { MESA_FORMAT_SIGNED_LA_LATC2, _mesa_texstore_signed_rg_rgtc2 }
};