[Piglit] [PATCH 2/2] gl-3.0/integer-errors: do more glTexImage parameter error checking
Brian Paul
brianp at vmware.com
Fri Jun 27 13:54:32 PDT 2014
Instead of spot checking a few internalFormat/format/type combinations
test all of them. And only test the core profile formats. The
ext_texture_integer-errors test hits the other legacy/compat formats.
Remove the tests for glDrawPixels, glReadPixels, etc. since that's
covered in the new ext_texture_integer-errors test.
Also, we were mistakenly checking that the packed datatypes were
accepted. But actually, the packed types were only made legal with
the GL_ARB_texture_rgb10_a2ui extension not GL_EXT_texture_integer.
---
tests/spec/gl-3.0/api/integer-errors.c | 179 +++++++++++---------------------
1 file changed, 63 insertions(+), 116 deletions(-)
diff --git a/tests/spec/gl-3.0/api/integer-errors.c b/tests/spec/gl-3.0/api/integer-errors.c
index 8323bb5..ccfd279 100644
--- a/tests/spec/gl-3.0/api/integer-errors.c
+++ b/tests/spec/gl-3.0/api/integer-errors.c
@@ -22,9 +22,7 @@
/**
* \file integer-errors.c
- * Do error checking for functions taking signed/unsigned integer
- * (non-normalized) formats, such as glTex[Sub]Image, glDrawPixels and
- * glReadPixels.
+ * Do error checking for OpenGL 3.0 glTexImage with integer formats/types.
*/
@@ -32,93 +30,11 @@
PIGLIT_GL_TEST_CONFIG_BEGIN
- config.supports_gl_compat_version = 10;
+ config.supports_gl_compat_version = 30;
config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
PIGLIT_GL_TEST_CONFIG_END
-static bool
-test_api_errors(void)
-{
- /* clear any prev errors */
- while (glGetError())
- ;
-
- /* use a new tex obj */
- glBindTexture(GL_TEXTURE_2D, 42);
-
- /* Check that glDrawPixels of integer data is illegal */
- {
- static const GLfloat pixel[4] = {0, 0, 0, 0};
-
- glDrawPixels(1, 1, GL_RGBA_INTEGER_EXT, GL_INT, pixel);
- if (!piglit_check_gl_error(GL_INVALID_OPERATION))
- return false;
- }
-
- /* Check glTexImage for invalid internalFormat/format/type combos */
- {
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16UI_EXT, 1, 1, 0,
- GL_RGBA_INTEGER, GL_FLOAT, NULL);
- if (!piglit_check_gl_error(GL_INVALID_ENUM))
- return false;
-
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 4, 4, 0,
- GL_RGBA_INTEGER, GL_SHORT, NULL);
- if (!piglit_check_gl_error(GL_INVALID_OPERATION))
- return false;
- }
-
- /* Check glTexSubImage for invalid format/type combination */
- {
- /* make valid texture image here */
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32UI_EXT, 8, 8, 0,
- GL_RGBA_INTEGER, GL_UNSIGNED_INT, NULL);
- if (!piglit_check_gl_error(GL_NO_ERROR))
- return false;
-
- glTexSubImage2D(GL_TEXTURE_2D, 0,
- 0, 0, 4, 4,
- GL_RGBA_INTEGER, GL_FLOAT, NULL);
- if (!piglit_check_gl_error(GL_INVALID_ENUM))
- return false;
- }
-
- /* Check for GL_INVALID_OPERATION when trying to copy framebuffer pixels
- * to an integer texture when the framebuffer is not an integer format.
- */
- {
- /* make valid texture image here */
- glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16UI_EXT, 4, 4, 0,
- GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, NULL);
- if (!piglit_check_gl_error(GL_NO_ERROR))
- return false;
-
- glCopyTexSubImage2D(GL_TEXTURE_2D, 0,
- 0, 0, 0, 0, 4, 4);
- if (!piglit_check_gl_error(GL_INVALID_OPERATION))
- return false;
- }
-
- /* Is GL_INVALID_ENUM generated by glReadPixels? */
- {
- GLfloat buf[64];
- glReadPixels(0, 0, 4, 4, GL_RGBA_INTEGER, GL_FLOAT, buf);
- if (!piglit_check_gl_error(GL_INVALID_ENUM))
- return false;
- }
-
- /* Is GL_INVALID_OPERATION generated by glReadPixels? */
- {
- GLuint buf[64];
- glReadPixels(0, 0, 4, 4, GL_RGBA_INTEGER, GL_UNSIGNED_INT, buf);
- if (!piglit_check_gl_error(GL_INVALID_OPERATION))
- return false;
- }
-
- return true;
-}
-
/**
* Test specific combinations of (internalFormat, format, type) with
@@ -127,37 +43,74 @@ test_api_errors(void)
static bool
test_teximage_format_combos(void)
{
- /* These format combinations should all work */
- struct {
- GLenum intFormat, srcFormat, srcType;
- } formats[] = {
- { GL_RGBA8UI_EXT, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE },
- { GL_RGBA8UI_EXT, GL_RGBA_INTEGER, GL_SHORT },
- { GL_RGBA8UI_EXT, GL_RGBA_INTEGER, GL_UNSIGNED_INT_8_8_8_8 },
- { GL_RGBA8UI_EXT, GL_BGRA_INTEGER, GL_UNSIGNED_INT_8_8_8_8 },
- { GL_LUMINANCE8I_EXT, GL_RGBA_INTEGER, GL_UNSIGNED_INT_8_8_8_8 },
- { GL_RGB16I_EXT, GL_RGB_INTEGER, GL_UNSIGNED_SHORT_5_6_5 },
- { GL_RGB32I_EXT, GL_RGB_INTEGER, GL_UNSIGNED_SHORT_5_6_5 }
+ static const GLenum intFormats[] = {
+ GL_R8UI,
+ GL_RG8UI,
+ GL_RGB8UI,
+ GL_RGBA8UI,
+
+ GL_R8I,
+ GL_RG8I,
+ GL_RGB8I,
+ GL_RGBA8I,
+
+ GL_R16UI,
+ GL_RG16UI,
+ GL_RGB16UI,
+ GL_RGBA16UI,
+
+ GL_R16I,
+ GL_RG16I,
+ GL_RGB16I,
+ GL_RGBA16I,
+
+ GL_R32UI,
+ GL_RG32UI,
+ GL_RGB32UI,
+ GL_RGBA32UI,
+
+ GL_R32I,
+ GL_RG32I,
+ GL_RGB32I,
+ GL_RGBA32I
};
- int i;
+ static const GLenum formats[] = {
+ GL_RED_INTEGER,
+ GL_GREEN_INTEGER,
+ GL_BLUE_INTEGER,
+ GL_ALPHA_INTEGER,
+ GL_RGB_INTEGER,
+ GL_BGR_INTEGER,
+ GL_RGBA_INTEGER,
+ GL_BGRA_INTEGER
+ };
+ static const GLenum types[] = {
+ GL_BYTE,
+ GL_UNSIGNED_BYTE,
+ GL_SHORT,
+ GL_UNSIGNED_SHORT,
+ GL_INT,
+ GL_UNSIGNED_INT
+ };
+ unsigned i, j, k;
GLenum err;
bool pass = GL_TRUE;
- while (glGetError() != GL_NO_ERROR)
- ;
-
- for (i = 0; i < ARRAY_SIZE(formats); i++) {
- glTexImage2D(GL_TEXTURE_2D, 0, formats[i].intFormat,
+ for (i = 0; i < ARRAY_SIZE(intFormats); i++)
+ for (j = 0; j < ARRAY_SIZE(formats); j++)
+ for (k = 0; k < ARRAY_SIZE(types); k++) {
+ glTexImage2D(GL_TEXTURE_2D, 0, intFormats[i],
16, 16, 0,
- formats[i].srcFormat, formats[i].srcType, NULL);
+ formats[j], types[k], NULL);
err = glGetError();
if (err != GL_NO_ERROR) {
fprintf(stderr,
- "integer-errors failure: glTexImage2D(0x%x, 0x%x, 0x%x)"
- " generated error 0x%x (case %d)\n",
- formats[i].intFormat,
- formats[i].srcFormat,
- formats[i].srcType, err, i);
+ "fail: glTexImage2D(%s, %s, %s)"
+ " generated error %s\n",
+ piglit_get_gl_enum_name(intFormats[i]),
+ piglit_get_gl_enum_name(formats[j]),
+ piglit_get_gl_enum_name(types[k]),
+ piglit_get_gl_enum_name(err));
pass = false;
}
}
@@ -177,13 +130,7 @@ piglit_display(void)
void
piglit_init(int argc, char **argv)
{
- bool pass;
-
- piglit_require_gl_version(30);
-
- pass = test_api_errors();
-
- pass = pass && test_teximage_format_combos();
+ bool pass = test_teximage_format_combos();
piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
}
--
1.7.10.4
More information about the Piglit
mailing list