summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2011-08-24 15:49:32 -0700
committerEric Anholt <eric@anholt.net>2011-08-28 20:54:41 -0700
commit84a043ffb317985d87ef48e9687a1dc361631166 (patch)
tree674b438bbe65ce7290cb6518c1a98c7626e0e6b0
parent2aeea018835a054ea34b008d5f0f77bf4a3c0644 (diff)
getteximage-formats: Test glGetTexImage() for internalformat vs format/type.HEADmaster
-rw-r--r--tests/texturing/CMakeLists.gl.txt1
-rw-r--r--tests/texturing/getteximage-formats.c496
-rw-r--r--tests/texturing/texture-formats.h459
3 files changed, 956 insertions, 0 deletions
diff --git a/tests/texturing/CMakeLists.gl.txt b/tests/texturing/CMakeLists.gl.txt
index 1ab3a9c0c..726af2db1 100644
--- a/tests/texturing/CMakeLists.gl.txt
+++ b/tests/texturing/CMakeLists.gl.txt
@@ -26,6 +26,7 @@ add_executable (gen-compressed-teximage gen-compressed-teximage.c)
add_executable (gen-nonzero-unit gen-nonzero-unit.c)
add_executable (gen-teximage gen-teximage.c)
add_executable (gen-texsubimage gen-texsubimage.c)
+add_executable (getteximage-formats getteximage-formats.c)
add_executable (getteximage-simple getteximage-simple.c)
add_executable (fragment-and-vertex-texturing fragment-and-vertex-texturing.c)
add_executable (levelclamp levelclamp.c)
diff --git a/tests/texturing/getteximage-formats.c b/tests/texturing/getteximage-formats.c
new file mode 100644
index 000000000..e32abbf9d
--- /dev/null
+++ b/tests/texturing/getteximage-formats.c
@@ -0,0 +1,496 @@
+/*
+ * Copyright © 2009-2010 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+/** @file fbo-getteximage-formats.c
+ *
+ * Tests that glGenerateMipmapEXT works correctly on 2D textures of
+ * various internalformats.
+ */
+
+#include "piglit-util.h"
+#include "texture-formats.h"
+
+float texture_values[2 * 2][4] = {
+ {0.0, 0.25, 0.5, 1.0}, /* Basic UNORM-representable numbers */
+ {-0.25, -0.5, -0.75, -1.0}, /* Basic SNORM-representable numbers */
+ {2.0, 4.0, 8.0, 16.0}, /* Basic float-representable numbers */
+ {-2.0, -4.0, -8.0, -16.0}, /* Basic float-representable numbers */
+};
+float depth_values[8 * 8];
+
+int piglit_width = 1;
+int piglit_height = 1;
+int piglit_window_mode = GLUT_RGB;
+
+static int
+create_tex(GLenum internalformat, GLenum baseformat, GLenum basetype)
+{
+ GLuint tex;
+
+ glGenTextures(1, &tex);
+ glBindTexture(GL_TEXTURE_2D, tex);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER,
+ GL_NEAREST);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+ GL_NEAREST_MIPMAP_NEAREST);
+
+ if (baseformat == GL_DEPTH_COMPONENT ||
+ baseformat == GL_DEPTH_STENCIL) {
+ /* From the GL 3.2 compatibility spec, page 213:
+ *
+ * "If the base internal format is DEPTH_STENCIL
+ * and format is not DEPTH_STENCIL, then the
+ * values of the stencil index texture components
+ * are undefined."
+ *
+ * For this test, we don't care about the stencil
+ * components because GetTexImage doesn't return them.
+ */
+
+ glTexImage2D(GL_TEXTURE_2D, 0, internalformat, 8, 8, 0,
+ GL_DEPTH_COMPONENT, GL_FLOAT, depth_values);
+ } else {
+ int w = 8;
+ int h = 8;
+ float values[w * h][4];
+ int x, y, i;
+
+ /* Expand the values by 4x4 so that we can get
+ * reasonable data for compressed textures.
+ */
+ for (x = 0; x < w; x++) {
+ for (y = 0; y < h; y++) {
+ for (i = 0; i < 4; i++) {
+ values[y * w + x][i] =
+ texture_values[(y / 4) * 2 +
+ (x / 4)][i];
+ }
+ }
+ }
+ glTexImage2D(GL_TEXTURE_2D, 0, internalformat, w, h, 0,
+ GL_RGBA, GL_FLOAT, values);
+ }
+
+ if (glGetError() != 0)
+ return 0;
+
+ return tex;
+}
+
+struct get_format {
+ GLenum type;
+ GLenum format;
+ void (*get_float_values)(int w, int h, void *packed, float *out);
+ float threshold[4];
+};
+
+void get_rgba_float(int w, int h, void *packed, float *out)
+{
+ memcpy(out, packed, w * h * 4 * sizeof(float));
+}
+
+void get_rgb_float(int w, int h, void *packed, float *out)
+{
+ float *in = packed;
+ int i;
+
+ for (i = 0; i < w * h; i++) {
+ out[4 * i + 0] = in[3 * i + 0];
+ out[4 * i + 1] = in[3 * i + 1];
+ out[4 * i + 2] = in[3 * i + 2];
+ out[4 * i + 3] = 1.0;
+ }
+}
+
+void get_alpha_float(int w, int h, void *packed, float *out)
+{
+ float *in = packed;
+ int i;
+
+ for (i = 0; i < w * h; i++) {
+ out[4 * i + 0] = 0.0;
+ out[4 * i + 1] = 0.0;
+ out[4 * i + 2] = 0.0;
+ out[4 * i + 3] = in[i];
+ }
+}
+
+#define EF (1.0 / 1024.0)
+#define E8 (1.0 / 256.0)
+#define E16 (1.0 / 65536.0)
+#define EINF 9999
+/* See page 315 of the GL 3.2 compatibility spec, table 4.9 */
+struct get_format get_formats[] = {
+ { GL_RGBA, GL_FLOAT, get_rgba_float, {E8, E8, E8, E8} },
+ { GL_RGB, GL_FLOAT, get_rgb_float, {E8, E8, E8, EINF} },
+ { GL_ALPHA, GL_FLOAT, get_alpha_float, {EINF, EINF, EINF, EF} },
+};
+
+static float
+clamp_unorm(float v)
+{
+ if (v < 0)
+ return 0;
+ if (v > 1)
+ return 1;
+ return v;
+}
+
+static float
+clamp_snorm(float v)
+{
+ if (v < -1)
+ return -1;
+ if (v > 1)
+ return 1;
+ return v;
+}
+
+static bool
+is_color_format(GLenum format)
+{
+ switch (format) {
+ case GL_DEPTH_COMPONENT:
+ case GL_DEPTH_COMPONENT16:
+ case GL_DEPTH_COMPONENT24:
+ case GL_DEPTH_COMPONENT32:
+ case GL_DEPTH_STENCIL:
+ case GL_DEPTH24_STENCIL8:
+ return false;
+ }
+
+ return true;
+}
+
+static bool
+test_getteximage(struct get_format *get_format, GLenum internalformat,
+ GLenum baseformat, GLenum basetype)
+{
+ int w = 8;
+ int h = 8;
+ char data[w * h * 4 * sizeof(float)];
+ float result[w * h * 4];
+ int x, y;
+ float threshold[4];
+ GLint r_size, g_size, b_size, l_size, a_size, i_size;
+
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
+ GL_TEXTURE_LUMINANCE_SIZE, &l_size);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
+ GL_TEXTURE_ALPHA_SIZE, &a_size);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
+ GL_TEXTURE_INTENSITY_SIZE, &i_size);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
+ GL_TEXTURE_RED_SIZE, &r_size);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
+ GL_TEXTURE_GREEN_SIZE, &g_size);
+ glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,
+ GL_TEXTURE_BLUE_SIZE, &b_size);
+
+ glGetTexImage(GL_TEXTURE_2D, 0, get_format->type, get_format->format,
+ data);
+
+ /* From the GL 3.2 compatibility spec, page 372 "Texture Queries". */
+ if (is_color_format(get_format->format) &&
+ !is_color_format(internalformat)) {
+ assert(glGetError() == GL_INVALID_OPERATION);
+ return true;
+ } else if (get_format->format == GL_DEPTH_COMPONENT &&
+ baseformat != GL_DEPTH_COMPONENT &&
+ baseformat != GL_DEPTH_STENCIL) {
+ assert(glGetError() == GL_INVALID_OPERATION);
+ return true;
+ } else if (get_format->format == GL_DEPTH_STENCIL &&
+ baseformat != GL_DEPTH_STENCIL) {
+ assert(glGetError() == GL_INVALID_OPERATION);
+ return true;
+ }
+ assert(glGetError() == 0);
+ /* FINISHME: integer formats errors */
+
+ get_format->get_float_values(w, h, data, result);
+
+ threshold[0] = get_format->threshold[0];
+ threshold[1] = get_format->threshold[1];
+ threshold[2] = get_format->threshold[2];
+ threshold[3] = get_format->threshold[3];
+
+ if (i_size) {
+ threshold[0] += 1.0 / (1 << i_size);
+ threshold[1] += 1.0 / (1 << i_size);
+ threshold[2] += 1.0 / (1 << i_size);
+ threshold[3] += 1.0 / (1 << i_size);
+ } else {
+ if (l_size) {
+ threshold[0] += 1.0 / (1 << l_size);
+ threshold[1] += 1.0 / (1 << l_size);
+ threshold[2] += 1.0 / (1 << l_size);
+ } else {
+ if (r_size)
+ threshold[0] += 1.0 / (1 << r_size);
+ if (g_size)
+ threshold[1] += 1.0 / (1 << g_size);
+ if (b_size)
+ threshold[2] += 1.0 / (1 << b_size);
+ }
+ if (a_size)
+ threshold[3] += 1.0 / (1 << a_size);
+ }
+
+ for (y = 0; y < w; y++) {
+ for (x = 0; x < h; x++) {
+ float *r = &result[(y * w + x) * 4];
+ float e[4];
+
+ memcpy(e, texture_values[y / 4 * 2 + x / 4],
+ 4 * sizeof(float));
+
+ /* Convert our expected value according to how
+ * the incoming data got stored in the
+ * texture. From the GL 3.2 compatibility
+ * spec, page 214, table 3.16: "Conversion
+ * from RGBA, depth, and stencil pixel
+ * components to internal texture
+ * ... components."
+ */
+ if (i_size) {
+ e[1] = e[0];
+ e[2] = e[0];
+ e[3] = e[0];
+ } else {
+ if (l_size) {
+ e[1] = e[0];
+ e[2] = e[0];
+ } else {
+ if (r_size == 0)
+ e[0] = 0.0;
+ if (g_size == 0)
+ e[1] = 0.0;
+ if (b_size == 0)
+ e[2] = 0.0;
+ }
+ if (a_size == 0) {
+ e[3] = 1.0;
+ }
+ }
+
+ switch (basetype) {
+ case GL_UNSIGNED_NORMALIZED:
+ e[0] = clamp_unorm(e[0]);
+ e[1] = clamp_unorm(e[1]);
+ e[2] = clamp_unorm(e[2]);
+ e[3] = clamp_unorm(e[3]);
+ break;
+ case GL_SIGNED_NORMALIZED:
+ e[0] = clamp_snorm(e[0]);
+ e[1] = clamp_snorm(e[1]);
+ e[2] = clamp_snorm(e[2]);
+ e[3] = clamp_snorm(e[3]);
+ break;
+ }
+
+ /* Now, convert our expected value according
+ * to how it should be read as an RGBA value
+ * as the input to the pixel pack pipeline.
+ * GL 3.2 compatibility spec, page 374, table
+ * 6.1: "Texture, table, and filter return
+ * values".
+ *
+ * To some extent, this duplicates the table
+ * 3.16 conversions above. GL_LUMINANCE and
+ * GL_INTENSITY have significant differences.
+ */
+ switch (baseformat) {
+ case GL_ALPHA:
+ e[0] = 0.0;
+ e[1] = 0.0;
+ e[2] = 0.0;
+ break;
+ case GL_LUMINANCE:
+ e[1] = 0.0;
+ e[2] = 0.0;
+ e[3] = 1.0;
+ break;
+ case GL_LUMINANCE_ALPHA:
+ e[1] = 0.0;
+ e[2] = 0.0;
+ break;
+ case GL_INTENSITY:
+ e[1] = 0.0;
+ e[2] = 0.0;
+ e[3] = 1.0;
+ break;
+ case GL_RED:
+ e[1] = 0.0;
+ e[2] = 0.0;
+ e[3] = 1.0;
+ break;
+ case GL_RG:
+ e[2] = 0.0;
+ e[3] = 1.0;
+ break;
+ case GL_RGB:
+ e[3] = 1.0;
+ break;
+ case GL_RGBA:
+ break;
+ }
+
+ /* FINISHME */
+
+ if (fabs(r[0] - e[0]) > threshold[0] ||
+ fabs(r[1] - e[1]) > threshold[1] ||
+ fabs(r[2] - e[2]) > threshold[2] ||
+ fabs(r[3] - e[3]) > threshold[3]) {
+ fprintf(stderr, " Texel %d,%d failed:\n",
+ x, y);
+ fprintf(stderr, " found (%f,%f,%f,%f)\n",
+ r[0], r[1], r[2], r[3]);
+ fprintf(stderr, " expected (%f,%f,%f,%f)\n",
+ e[0], e[1], e[2], e[3]);
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
+static GLboolean
+test_format(const struct format_desc *format, GLenum basetype)
+{
+ GLuint tex;
+ bool pass = true;
+ int i;
+
+ printf("Testing %s\n", format->name);
+
+ tex = create_tex(format->internalformat, format->baseformat, basetype);
+
+ if (!tex) {
+ fprintf(stderr, "Failed to create texture. Ignoring %s\n",
+ format->name);
+ return true;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(get_formats); i++) {
+ if (!test_getteximage(&get_formats[i], format->internalformat,
+ format->baseformat, basetype)) {
+ pass = false;
+ break;
+ }
+ }
+
+ glDeleteTextures(1, &tex);
+
+ return pass;
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ return PIGLIT_FAIL;
+}
+
+bool supported(const struct test_desc *test_set, bool require)
+{
+ int i;
+
+ for (i = 0; i < 3; i++) {
+ if (!test_set->ext[i])
+ break;
+
+ if (require) {
+ piglit_require_extension(test_set->ext[i]);
+ } else {
+ if (!piglit_is_extension_supported(test_set->ext[i]))
+ return false;
+ }
+ }
+
+ return true;
+}
+
+void piglit_init(int argc, char **argv)
+{
+ bool pass = true;
+ bool run_all = false;
+ int i, j;
+ const struct test_desc *test_set;
+
+ test_set = &test_sets[0];
+
+ /* Initialize the gradient we use for depth texture values.
+ * The color textures have a different fixed data set.
+ */
+ for (i = 0; i < 8 * 8; i++) {
+ depth_values[i] = -2.0 + 4.0 * i / (8 * 8);
+ }
+
+ for (i = 1; i < argc; i++) {
+ if (!strcmp(argv[i], "-all")) {
+ run_all = true;
+ break;
+ }
+
+ for (j = 1; j < ARRAY_SIZE(test_sets); j++) {
+ if (!strcmp(argv[i], test_sets[j].param)) {
+ test_set = &test_sets[j];
+ if (!supported(test_set, true))
+ piglit_report_result(PIGLIT_SKIP);
+ break;
+ }
+ }
+ if (j == ARRAY_SIZE(test_sets)) {
+ fprintf(stderr, "Unknown argument: %s\n", argv[i]);
+ exit(1);
+ }
+ }
+
+ if (run_all) {
+ int t;
+ for (t = 0; t < ARRAY_SIZE(test_sets); t++) {
+ test_set = &test_sets[t];
+ if (!supported(test_set, false))
+ continue;
+
+ for (i = 0; i < test_set->num_formats; i++) {
+ pass &= test_format(&test_set->format[i],
+ test_set->basetype);
+ }
+ }
+ } else {
+ for (i = 0; i < test_set->num_formats; i++) {
+ pass &= test_format(&test_set->format[i],
+ test_set->basetype);
+ }
+ }
+
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
diff --git a/tests/texturing/texture-formats.h b/tests/texturing/texture-formats.h
new file mode 100644
index 000000000..ac4fa51db
--- /dev/null
+++ b/tests/texturing/texture-formats.h
@@ -0,0 +1,459 @@
+/*
+ * Copyright © 2009-2010 Intel Corporation
+ *
+ * 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.
+ *
+ * Authors:
+ * Eric Anholt <eric@anholt.net>
+ *
+ */
+
+
+struct format_desc {
+ GLenum internalformat;
+ char *name;
+ GLenum baseformat;
+};
+
+#define FORMAT(f, baseformat) { f, #f, baseformat }
+static const struct format_desc core[] = {
+ FORMAT(3, GL_RGB),
+ FORMAT(4, GL_RGBA),
+ FORMAT(GL_RGB, GL_RGB),
+ FORMAT(GL_RGBA, GL_RGBA),
+ FORMAT(GL_ALPHA, GL_ALPHA),
+ FORMAT(GL_LUMINANCE, GL_LUMINANCE),
+ FORMAT(GL_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_INTENSITY, GL_INTENSITY),
+
+ FORMAT(GL_ALPHA4, GL_ALPHA),
+ FORMAT(GL_ALPHA8, GL_ALPHA),
+ FORMAT(GL_ALPHA12, GL_ALPHA),
+ FORMAT(GL_ALPHA16, GL_ALPHA),
+
+ FORMAT(GL_LUMINANCE4, GL_LUMINANCE),
+ FORMAT(GL_LUMINANCE8, GL_LUMINANCE),
+ FORMAT(GL_LUMINANCE12, GL_LUMINANCE),
+ FORMAT(GL_LUMINANCE16, GL_LUMINANCE),
+
+ FORMAT(GL_LUMINANCE4_ALPHA4, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_LUMINANCE8_ALPHA8, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_LUMINANCE12_ALPHA12, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_LUMINANCE16_ALPHA16, GL_LUMINANCE_ALPHA),
+
+ FORMAT(GL_INTENSITY4, GL_INTENSITY),
+ FORMAT(GL_INTENSITY8, GL_INTENSITY),
+ FORMAT(GL_INTENSITY12, GL_INTENSITY),
+ FORMAT(GL_INTENSITY16, GL_INTENSITY),
+
+ FORMAT(GL_R3_G3_B2, GL_RGB),
+ FORMAT(GL_RGB4, GL_RGB),
+ FORMAT(GL_RGB5, GL_RGB),
+ FORMAT(GL_RGB8, GL_RGB),
+ FORMAT(GL_RGB10, GL_RGB),
+ FORMAT(GL_RGB12, GL_RGB),
+ FORMAT(GL_RGB16, GL_RGB),
+
+ FORMAT(GL_RGBA2, GL_RGBA),
+ FORMAT(GL_RGBA4, GL_RGBA),
+ FORMAT(GL_RGB5_A1, GL_RGBA),
+ FORMAT(GL_RGBA8, GL_RGBA),
+ FORMAT(GL_RGB10_A2, GL_RGBA),
+ FORMAT(GL_RGBA12, GL_RGBA),
+ FORMAT(GL_RGBA16, GL_RGBA),
+};
+
+static const struct format_desc arb_depth_texture[] = {
+ FORMAT(GL_DEPTH_COMPONENT, GL_DEPTH_COMPONENT),
+ FORMAT(GL_DEPTH_COMPONENT16, GL_DEPTH_COMPONENT),
+ FORMAT(GL_DEPTH_COMPONENT24, GL_DEPTH_COMPONENT),
+ FORMAT(GL_DEPTH_COMPONENT32, GL_DEPTH_COMPONENT),
+};
+
+static const struct format_desc ext_packed_depth_stencil[] = {
+ FORMAT(GL_DEPTH_STENCIL_EXT, GL_DEPTH_STENCIL_EXT),
+ FORMAT(GL_DEPTH24_STENCIL8_EXT, GL_DEPTH_STENCIL_EXT),
+};
+
+static const struct format_desc ext_texture_srgb[] = {
+ FORMAT(GL_SRGB_EXT, GL_RGB),
+ FORMAT(GL_SRGB8_EXT, GL_RGB),
+ FORMAT(GL_SRGB_ALPHA_EXT, GL_RGBA),
+ FORMAT(GL_SRGB8_ALPHA8_EXT, GL_RGBA),
+ FORMAT(GL_SLUMINANCE_ALPHA_EXT, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_SLUMINANCE8_ALPHA8_EXT, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_SLUMINANCE_EXT, GL_LUMINANCE),
+ FORMAT(GL_SLUMINANCE8_EXT, GL_LUMINANCE),
+};
+
+static const struct format_desc ext_texture_srgb_compressed[] = {
+ FORMAT(GL_COMPRESSED_SRGB_EXT, GL_RGB),
+ FORMAT(GL_COMPRESSED_SRGB_S3TC_DXT1_EXT, GL_RGB),
+ FORMAT(GL_COMPRESSED_SRGB_ALPHA_EXT, GL_RGBA),
+ FORMAT(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_RGBA),
+ FORMAT(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_RGBA),
+ FORMAT(GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_RGBA),
+ FORMAT(GL_COMPRESSED_SLUMINANCE_ALPHA_EXT, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_COMPRESSED_SLUMINANCE_EXT, GL_LUMINANCE),
+};
+
+static const struct format_desc ext_texture_compression[] = {
+ FORMAT(GL_COMPRESSED_ALPHA, GL_ALPHA),
+ FORMAT(GL_COMPRESSED_LUMINANCE, GL_LUMINANCE),
+ FORMAT(GL_COMPRESSED_LUMINANCE_ALPHA, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_COMPRESSED_INTENSITY, GL_INTENSITY),
+ FORMAT(GL_COMPRESSED_RGB, GL_RGB),
+ FORMAT(GL_COMPRESSED_RGBA, GL_RGBA),
+};
+
+static const struct format_desc tdfx_texture_compression_fxt1[] = {
+ FORMAT(GL_COMPRESSED_RGB_FXT1_3DFX, GL_RGB),
+ FORMAT(GL_COMPRESSED_RGBA_FXT1_3DFX, GL_RGBA),
+};
+
+static const struct format_desc ext_texture_compression_s3tc[] = {
+ FORMAT(GL_COMPRESSED_RGB_S3TC_DXT1_EXT, GL_RGB),
+ FORMAT(GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_RGBA),
+ FORMAT(GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA),
+ FORMAT(GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA),
+};
+
+static const struct format_desc ext_texture_integer[] = {
+ FORMAT(GL_RGBA8UI_EXT, GL_RGBA),
+ FORMAT(GL_RGBA16UI_EXT, GL_RGBA),
+ FORMAT(GL_RGBA32UI_EXT, GL_RGBA),
+ FORMAT(GL_RGBA8I_EXT, GL_RGBA),
+ FORMAT(GL_RGBA16I_EXT, GL_RGBA),
+ FORMAT(GL_RGBA32I_EXT, GL_RGBA),
+ FORMAT(GL_RGB8UI_EXT, GL_RGB),
+ FORMAT(GL_RGB16UI_EXT, GL_RGB),
+ FORMAT(GL_RGB32UI_EXT, GL_RGB),
+ FORMAT(GL_RGB8I_EXT, GL_RGB),
+ FORMAT(GL_RGB16I_EXT, GL_RGB),
+ FORMAT(GL_RGB32I_EXT, GL_RGB),
+ FORMAT(GL_ALPHA8UI_EXT, GL_ALPHA),
+ FORMAT(GL_ALPHA16UI_EXT, GL_ALPHA),
+ FORMAT(GL_ALPHA32UI_EXT, GL_ALPHA),
+ FORMAT(GL_ALPHA8I_EXT, GL_ALPHA),
+ FORMAT(GL_ALPHA16I_EXT, GL_ALPHA),
+ FORMAT(GL_ALPHA32I_EXT, GL_ALPHA),
+ FORMAT(GL_INTENSITY8UI_EXT, GL_INTENSITY),
+ FORMAT(GL_INTENSITY16UI_EXT, GL_INTENSITY),
+ FORMAT(GL_INTENSITY32UI_EXT, GL_INTENSITY),
+ FORMAT(GL_INTENSITY8I_EXT, GL_INTENSITY),
+ FORMAT(GL_INTENSITY16I_EXT, GL_INTENSITY),
+ FORMAT(GL_INTENSITY32I_EXT, GL_INTENSITY),
+ FORMAT(GL_LUMINANCE8UI_EXT, GL_LUMINANCE),
+ FORMAT(GL_LUMINANCE16UI_EXT, GL_LUMINANCE),
+ FORMAT(GL_LUMINANCE32UI_EXT, GL_LUMINANCE),
+ FORMAT(GL_LUMINANCE8I_EXT, GL_LUMINANCE),
+ FORMAT(GL_LUMINANCE16I_EXT, GL_LUMINANCE),
+ FORMAT(GL_LUMINANCE32I_EXT, GL_LUMINANCE),
+ FORMAT(GL_LUMINANCE_ALPHA8UI_EXT, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_LUMINANCE_ALPHA16UI_EXT, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_LUMINANCE_ALPHA32UI_EXT, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_LUMINANCE_ALPHA8I_EXT, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_LUMINANCE_ALPHA16I_EXT, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_LUMINANCE_ALPHA32I_EXT, GL_LUMINANCE_ALPHA),
+};
+
+static const struct format_desc arb_texture_rg[] = {
+ FORMAT(GL_RED, GL_RED),
+ FORMAT(GL_R8, GL_RED),
+ FORMAT(GL_R16, GL_RED),
+ FORMAT(GL_RG, GL_RG),
+ FORMAT(GL_RG8, GL_RG),
+ FORMAT(GL_RG16, GL_RG),
+};
+
+static const struct format_desc arb_texture_rg_int[] = {
+ FORMAT(GL_RED_INTEGER, GL_RED),
+ FORMAT(GL_R8I, GL_RED),
+ FORMAT(GL_R8UI, GL_RED),
+ FORMAT(GL_R16I, GL_RED),
+ FORMAT(GL_R16UI, GL_RED),
+ FORMAT(GL_R32I, GL_RED),
+ FORMAT(GL_R32UI, GL_RED),
+ FORMAT(GL_RG_INTEGER, GL_RG),
+ FORMAT(GL_RG8I, GL_RG),
+ FORMAT(GL_RG8UI, GL_RG),
+ FORMAT(GL_RG16I, GL_RG),
+ FORMAT(GL_RG16UI, GL_RG),
+ FORMAT(GL_RG32I, GL_RG),
+ FORMAT(GL_RG32UI, GL_RG),
+};
+
+static const struct format_desc arb_texture_rg_float[] = {
+ FORMAT(GL_R16F, GL_RED),
+ FORMAT(GL_R32F, GL_RED),
+ FORMAT(GL_RG16F, GL_RG),
+ FORMAT(GL_RG32F, GL_RG),
+};
+
+static const struct format_desc ext_texture_shared_exponent[] = {
+ FORMAT(GL_RGB9_E5_EXT, GL_RGB),
+};
+
+static const struct format_desc ext_packed_float[] = {
+ FORMAT(GL_R11F_G11F_B10F_EXT, GL_RGB),
+};
+
+static const struct format_desc arb_depth_buffer_float[] = {
+ FORMAT(GL_DEPTH_COMPONENT32F, GL_DEPTH_COMPONENT),
+ FORMAT(GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL),
+};
+
+static const struct format_desc ext_texture_compression_rgtc[] = {
+ FORMAT(GL_COMPRESSED_RED, GL_RED),
+ FORMAT(GL_COMPRESSED_RED_RGTC1_EXT, GL_RED),
+ FORMAT(GL_COMPRESSED_RG, GL_RG),
+ FORMAT(GL_COMPRESSED_RED_GREEN_RGTC2_EXT, GL_RG),
+};
+
+static const struct format_desc ext_texture_compression_rgtc_signed[] = {
+ FORMAT(GL_COMPRESSED_SIGNED_RED_RGTC1_EXT, GL_RED),
+ FORMAT(GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT, GL_RG),
+};
+
+static const struct format_desc arb_texture_float[] = {
+ FORMAT(GL_RGB16F_ARB, GL_RGB),
+ FORMAT(GL_RGBA16F_ARB, GL_RGBA),
+ FORMAT(GL_ALPHA16F_ARB, GL_ALPHA),
+ FORMAT(GL_LUMINANCE16F_ARB, GL_LUMINANCE),
+ FORMAT(GL_LUMINANCE_ALPHA16F_ARB, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_INTENSITY16F_ARB, GL_INTENSITY),
+ FORMAT(GL_RGB32F_ARB, GL_RGB),
+ FORMAT(GL_RGBA32F_ARB, GL_RGBA),
+ FORMAT(GL_ALPHA32F_ARB, GL_ALPHA),
+ FORMAT(GL_LUMINANCE32F_ARB, GL_LUMINANCE),
+ FORMAT(GL_LUMINANCE_ALPHA32F_ARB, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_INTENSITY32F_ARB, GL_INTENSITY)
+};
+
+static const struct format_desc ati_texture_compression_3dc[] = {
+ FORMAT(GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI, GL_LUMINANCE_ALPHA)
+};
+
+static const struct format_desc ext_texture_compression_latc[] = {
+ FORMAT(GL_COMPRESSED_LUMINANCE_LATC1_EXT, GL_LUMINANCE),
+ FORMAT(GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT, GL_LUMINANCE_ALPHA),
+};
+
+static const struct format_desc ext_texture_compression_latc_signed[] = {
+ FORMAT(GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT, GL_LUMINANCE),
+ FORMAT(GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT, GL_LUMINANCE_ALPHA)
+};
+
+static const struct format_desc ext_texture_snorm[] = {
+ FORMAT(GL_RED_SNORM, GL_RED),
+ FORMAT(GL_R8_SNORM, GL_RED),
+ FORMAT(GL_RG_SNORM, GL_RG),
+ FORMAT(GL_RG8_SNORM, GL_RG),
+ FORMAT(GL_RGB_SNORM, GL_RGB),
+ FORMAT(GL_RGB8_SNORM, GL_RGB),
+ FORMAT(GL_RGBA_SNORM, GL_RGBA),
+ FORMAT(GL_RGBA8_SNORM, GL_RGBA),
+ FORMAT(GL_ALPHA_SNORM, GL_ALPHA),
+ FORMAT(GL_ALPHA8_SNORM, GL_ALPHA),
+ FORMAT(GL_LUMINANCE_SNORM, GL_LUMINANCE),
+ FORMAT(GL_LUMINANCE8_SNORM, GL_LUMINANCE),
+ FORMAT(GL_LUMINANCE_ALPHA_SNORM, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_LUMINANCE8_ALPHA8_SNORM, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_INTENSITY_SNORM, GL_INTENSITY),
+ FORMAT(GL_INTENSITY8_SNORM, GL_INTENSITY),
+ FORMAT(GL_R16_SNORM, GL_RED),
+ FORMAT(GL_RG16_SNORM, GL_RG),
+ FORMAT(GL_RGB16_SNORM, GL_RGB),
+ FORMAT(GL_RGBA16_SNORM, GL_RGBA),
+ FORMAT(GL_ALPHA16_SNORM, GL_ALPHA),
+ FORMAT(GL_LUMINANCE16_SNORM, GL_LUMINANCE),
+ FORMAT(GL_LUMINANCE16_ALPHA16_SNORM, GL_LUMINANCE_ALPHA),
+ FORMAT(GL_INTENSITY16_SNORM, GL_INTENSITY)
+};
+
+struct test_desc {
+ const struct format_desc *format;
+ unsigned num_formats;
+ const char *param;
+ GLenum basetype;
+ const char *ext[3];
+};
+
+static const struct test_desc test_sets[] = {
+ {
+ core,
+ ARRAY_SIZE(core),
+ "Core formats",
+ GL_UNSIGNED_NORMALIZED,
+ },
+ {
+ ext_texture_compression,
+ ARRAY_SIZE(ext_texture_compression),
+ "GL_ARB_texture_compression",
+ GL_UNSIGNED_NORMALIZED,
+ {"GL_ARB_texture_compression"}
+ },
+ {
+ tdfx_texture_compression_fxt1,
+ ARRAY_SIZE(tdfx_texture_compression_fxt1),
+ "GL_3DFX_texture_compression_FXT1",
+ GL_UNSIGNED_NORMALIZED,
+ {"GL_ARB_texture_compression",
+ "GL_3DFX_texture_compression_FXT1"},
+ },
+ {
+ ext_texture_compression_s3tc,
+ ARRAY_SIZE(ext_texture_compression_s3tc),
+ "GL_EXT_texture_compression_s3tc",
+ GL_UNSIGNED_NORMALIZED,
+ {"GL_ARB_texture_compression",
+ "GL_EXT_texture_compression_s3tc"},
+ },
+ {
+ arb_depth_texture,
+ ARRAY_SIZE(arb_depth_texture),
+ "GL_ARB_depth_texture",
+ GL_UNSIGNED_NORMALIZED,
+ {"GL_ARB_depth_texture"},
+ },
+ {
+ ext_packed_depth_stencil,
+ ARRAY_SIZE(ext_packed_depth_stencil),
+ "GL_EXT_packed_depth_stencil",
+ GL_UNSIGNED_NORMALIZED,
+ {"GL_EXT_packed_depth_stencil"},
+ },
+ {
+ ext_texture_srgb,
+ ARRAY_SIZE(ext_texture_srgb),
+ "GL_EXT_texture_sRGB",
+ GL_UNSIGNED_NORMALIZED,
+ {"GL_EXT_texture_sRGB"}
+ },
+ {
+ ext_texture_srgb_compressed,
+ ARRAY_SIZE(ext_texture_srgb_compressed),
+ "GL_EXT_texture_sRGB-s3tc",
+ GL_UNSIGNED_NORMALIZED,
+ {"GL_EXT_texture_sRGB",
+ "GL_ARB_texture_compression",
+ "GL_EXT_texture_compression_s3tc"},
+ },
+ {
+ ext_texture_integer,
+ ARRAY_SIZE(ext_texture_integer),
+ "GL_EXT_texture_integer",
+ GL_INT,
+ {"GL_EXT_texture_integer"}
+ },
+ {
+ arb_texture_rg,
+ ARRAY_SIZE(arb_texture_rg),
+ "GL_ARB_texture_rg",
+ GL_UNSIGNED_NORMALIZED,
+ {"GL_ARB_texture_rg"}
+ },
+ {
+ arb_texture_rg_int,
+ ARRAY_SIZE(arb_texture_rg_int),
+ "GL_ARB_texture_rg-int",
+ GL_INT,
+ {"GL_ARB_texture_rg",
+ "GL_EXT_texture_integer"}
+ },
+ {
+ arb_texture_rg_float,
+ ARRAY_SIZE(arb_texture_rg_float),
+ "GL_ARB_texture_rg-float",
+ GL_FLOAT,
+ {"GL_ARB_texture_rg",
+ "GL_ARB_texture_float"}
+ },
+ {
+ ext_texture_shared_exponent,
+ ARRAY_SIZE(ext_texture_shared_exponent),
+ "GL_EXT_texture_shared_exponent",
+ GL_UNSIGNED_NORMALIZED, /* XXX UNSIGNED_FLOAT */
+ {"GL_EXT_texture_shared_exponent"}
+ },
+ {
+ ext_packed_float,
+ ARRAY_SIZE(ext_packed_float),
+ "GL_EXT_packed_float",
+ GL_UNSIGNED_NORMALIZED, /* XXX UNSIGNED_FLOAT */
+ {"GL_EXT_packed_float"}
+ },
+ {
+ arb_depth_buffer_float,
+ ARRAY_SIZE(arb_depth_buffer_float),
+ "GL_ARB_depth_buffer_float",
+ GL_FLOAT,
+ {"GL_ARB_depth_buffer_float"},
+ },
+ {
+ ext_texture_compression_rgtc,
+ ARRAY_SIZE(ext_texture_compression_rgtc),
+ "GL_EXT_texture_compression_rgtc",
+ GL_UNSIGNED_NORMALIZED,
+ {"GL_EXT_texture_compression_rgtc"}
+ },
+ {
+ ext_texture_compression_rgtc_signed,
+ ARRAY_SIZE(ext_texture_compression_rgtc_signed),
+ "GL_EXT_texture_compression_rgtc-signed",
+ GL_SIGNED_NORMALIZED,
+ {"GL_EXT_texture_compression_rgtc"}
+ },
+ {
+ arb_texture_float,
+ ARRAY_SIZE(arb_texture_float),
+ "GL_ARB_texture_float",
+ GL_FLOAT,
+ {"GL_ARB_texture_float"}
+ },
+ {
+ ati_texture_compression_3dc,
+ ARRAY_SIZE(ati_texture_compression_3dc),
+ "GL_ATI_texture_compression_3dc",
+ GL_UNSIGNED_NORMALIZED,
+ {"GL_ATI_texture_compression_3dc"}
+ },
+ {
+ ext_texture_compression_latc,
+ ARRAY_SIZE(ext_texture_compression_latc),
+ "GL_EXT_texture_compression_latc",
+ GL_UNSIGNED_NORMALIZED,
+ {"GL_EXT_texture_compression_latc"}
+ },
+ {
+ ext_texture_compression_latc_signed,
+ ARRAY_SIZE(ext_texture_compression_latc_signed),
+ "GL_EXT_texture_compression_latc-signed",
+ GL_SIGNED_NORMALIZED,
+ {"GL_EXT_texture_compression_latc"}
+ },
+ {
+ ext_texture_snorm,
+ ARRAY_SIZE(ext_texture_snorm),
+ "GL_EXT_texture_snorm",
+ GL_SIGNED_NORMALIZED,
+ {"GL_EXT_texture_snorm"}
+ },
+};