summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIlia Mirkin <imirkin@alum.mit.edu>2019-09-02 18:46:11 -0400
committerIlia Mirkin <imirkin@alum.mit.edu>2019-09-04 00:34:45 -0400
commitde903f1f3b52e9b2a00f2dd7df58e06667cecb5f (patch)
tree9253c4f4812c5ed97f8fb071ede23b629e0b23be
parentbb5b0659f370cefd98e1520205b018a317a34990 (diff)
teximage-errors: add TexSubImage variants
Mesa is not currently checking compatibility of format + internal format when doing a TexSubImage. This implements these checks by doing a glTexStorage followed by glTexSubImage. (The dependency on TexStorage could be avoided, but would require more changes to the test structure.) Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu> Reviewed-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--tests/texturing/teximage-errors.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/tests/texturing/teximage-errors.c b/tests/texturing/teximage-errors.c
index 444ef3411..47d5d28e4 100644
--- a/tests/texturing/teximage-errors.c
+++ b/tests/texturing/teximage-errors.c
@@ -230,6 +230,58 @@ test_depth_formats(const struct format_desc *test, GLenum expected_error,
}
return result;
}
+
+/* Test the combinations of depth formats in glTexSubImage{123}D() */
+static bool
+test_depth_formats_storage(const struct format_desc *test, GLenum expected_error,
+ GLint n_tests)
+{
+ int i;
+ bool result = true;
+ char buffer[16 * 16 * 16 * 8] = {0};
+ GLuint tex[3];
+
+ /* Not strictly required, but makes the test simpler */
+ if (!piglit_is_extension_supported("GL_ARB_texture_storage"))
+ return true;
+
+ for (i = 0; i < n_tests; i++, glDeleteTextures(3, tex)) {
+ glGenTextures(3, tex);
+
+ if ((test[i].internalformat == GL_DEPTH_COMPONENT32F ||
+ test[i].internalformat == GL_DEPTH32F_STENCIL8) &&
+ !piglit_is_extension_supported("GL_ARB_depth_buffer_float"))
+ continue;
+
+ glBindTexture(GL_TEXTURE_1D, tex[0]);
+ glBindTexture(GL_TEXTURE_2D, tex[1]);
+ glBindTexture(GL_TEXTURE_2D_ARRAY, tex[2]);
+
+ glTexStorage1D(GL_TEXTURE_1D, 1, test[i].internalformat, 16);
+ result = piglit_check_gl_error(GL_NO_ERROR) && result;
+ glTexSubImage1D(GL_TEXTURE_1D, 0, 0, 16,
+ test[i].format, test[i].type, buffer);
+ result = piglit_check_gl_error(expected_error) && result;
+
+ glTexStorage2D(GL_TEXTURE_2D, 1, test[i].internalformat, 16, 16);
+ result = piglit_check_gl_error(GL_NO_ERROR) && result;
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 16, 16,
+ test[i].format, test[i].type, buffer);
+ result = piglit_check_gl_error(expected_error) && result;
+
+ if (!piglit_is_extension_supported("GL_EXT_texture_array"))
+ continue;
+
+ glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, test[i].internalformat,
+ 16, 16, 16);
+ result = piglit_check_gl_error(GL_NO_ERROR) && result;
+ glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 16, 16, 16,
+ test[i].format, test[i].type, buffer);
+ result = piglit_check_gl_error(expected_error) && result;
+ }
+ return result;
+}
+
enum piglit_result
piglit_display(void)
{
@@ -256,6 +308,13 @@ piglit_display(void)
pass = test_depth_formats(formats_not_allowed, GL_INVALID_OPERATION,
ARRAY_SIZE(formats_not_allowed))
&& pass;
+
+ pass = test_depth_formats_storage(formats_allowed, GL_NO_ERROR,
+ ARRAY_SIZE(formats_allowed))
+ && pass;
+ pass = test_depth_formats_storage(formats_not_allowed, GL_INVALID_OPERATION,
+ ARRAY_SIZE(formats_not_allowed))
+ && pass;
}
return pass ? PIGLIT_PASS: PIGLIT_FAIL;