[Piglit] [PATCH] gl-3.1: Add testing for updated required sized texture formats.
Eric Anholt
eric at anholt.net
Mon Jul 30 09:33:52 PDT 2012
---
tests/all.tests | 3 +-
tests/spec/gl-3.0/required-sized-texture-formats.c | 45 +++++++++++++++++---
tests/util/sized-internalformats.c | 14 ++++++
tests/util/sized-internalformats.h | 1 +
4 files changed, 56 insertions(+), 7 deletions(-)
diff --git a/tests/all.tests b/tests/all.tests
index 8c32665..5cf0e17 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -938,7 +938,7 @@ add_concurrent_test(gl30, 'clearbuffer-stencil')
add_concurrent_test(gl30, 'getfragdatalocation')
add_concurrent_test(gl30, 'integer-errors')
gl30['minmax'] = concurrent_test('gl-3.0-minmax')
-add_concurrent_test(gl30, 'gl-3.0-required-sized-texture-formats')
+gl30['required-sized-texture-formats'] = concurrent_test('gl-3.0-required-sized-texture-formats 30')
add_concurrent_test(gl30, 'gl-3.0-required-renderbuffer-attachment-formats')
add_concurrent_test(gl30, 'gl-3.0-required-texture-attachment-formats')
add_concurrent_test(gl30, 'gl-3.0-texture-integer')
@@ -946,6 +946,7 @@ add_concurrent_test(gl30, 'gl-3.0-texture-integer')
gl31 = Group()
spec['!OpenGL 3.1'] = gl31
gl31['minmax'] = concurrent_test('gl-3.1-minmax')
+gl31['required-sized-texture-formats'] = concurrent_test('gl-3.0-required-sized-texture-formats 31')
# Group spec/glsl-1.00
spec['glsl-1.00'] = Group()
diff --git a/tests/spec/gl-3.0/required-sized-texture-formats.c b/tests/spec/gl-3.0/required-sized-texture-formats.c
index 21c7849..b680e6d 100644
--- a/tests/spec/gl-3.0/required-sized-texture-formats.c
+++ b/tests/spec/gl-3.0/required-sized-texture-formats.c
@@ -35,6 +35,16 @@
* internal formats for any texture type will allocate exactly
* the internal component sizes and types shown for that format
* in tables 3.16- 3.17:"
+ *
+ * In GL 3.1 this is changed to be at least. Page 119 of the GL 3.1
+ * core spec pds (20090528):
+ *
+ * "In addition, implementations are required to support the
+ * following sized and compressed internal formats. Requesting
+ * one of these sized internal formats for any texture type will
+ * allocate at least the internal component sizes, and exactly
+ * the component types shown for that format in tables 3.12-
+ * 3.13: "
*/
PIGLIT_GL_TEST_MAIN(
@@ -71,18 +81,32 @@ piglit_display(void)
return PIGLIT_FAIL;
}
+static void
+usage(const char *name)
+{
+ fprintf(stderr, "usage: %s <30 | 31>\n", name);
+ piglit_report_result(PIGLIT_FAIL);
+}
+
void
piglit_init(int argc, char **argv)
{
bool pass = true;
GLuint tex;
int i, c;
+ int target_version;
- if (piglit_get_gl_version() < 30) {
- printf("Requires GL 3.0\n");
- piglit_report_result(PIGLIT_SKIP);
+ if (argc != 2)
+ usage(argv[0]);
+ target_version = strtol(argv[1], NULL, 0);
+
+ if (!(target_version == 30 || target_version == 31)) {
+ fprintf(stderr, "Unknown version number %d\n", target_version);
+ usage(argv[0]);
}
+ piglit_require_gl_version(target_version);
+
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
@@ -93,11 +117,16 @@ piglit_init(int argc, char **argv)
GLenum format, type;
const struct sized_internalformat *f;
- /* FINISHME: Add support for future GL versions. */
- if (required_formats[i].version != 30)
+ if (target_version < required_formats[i].version)
continue;
f = get_sized_internalformat(required_formats[i].token);
+ if (!f) {
+ printf("Failed to get sized format for %s\n",
+ piglit_get_gl_enum_name(required_formats[i].token));
+ pass = false;
+ continue;
+ }
if (f->token == GL_DEPTH24_STENCIL8 ||
f->token == GL_DEPTH32F_STENCIL8) {
@@ -182,10 +211,14 @@ piglit_init(int argc, char **argv)
f->bits[c] == UCMP) {
if (sizes[c] <= 0 || sizes[c] > 8)
format_pass = false;
- } else {
+ } else if (target_version == 30) {
if (sizes[c] != get_channel_size(f, c)) {
format_pass = false;
}
+ } else {
+ if (sizes[c] < get_channel_size(f, c)) {
+ format_pass = false;
+ }
}
if (types[c] != get_channel_type(f, c))
diff --git a/tests/util/sized-internalformats.c b/tests/util/sized-internalformats.c
index 406aee4..c396418 100644
--- a/tests/util/sized-internalformats.c
+++ b/tests/util/sized-internalformats.c
@@ -41,6 +41,7 @@ static const struct {
{ 24, GL_UNSIGNED_NORMALIZED },
{ 16, GL_UNSIGNED_NORMALIZED },
+ { 16, GL_SIGNED_NORMALIZED },
{ 16, GL_FLOAT },
{ 16, GL_INT },
{ 16, GL_UNSIGNED_INT },
@@ -130,6 +131,19 @@ const struct sized_internalformat sized_internalformats[] = {
FORMAT(GL_RGBA32I, I32, I32, I32, I32, NONE, NONE, NONE, NONE),
FORMAT(GL_RGBA32UI, U32, U32, U32, U32, NONE, NONE, NONE, NONE),
+ /* SNORM formats introduced as required sized texture formats
+ * in GL 3.1, but didn't get sizes actually specified until GL
+ * 3.2's table 3.12.
+ */
+ FORMAT(GL_R8_SNORM, SN8, NONE, NONE, NONE, NONE, NONE, NONE, NONE),
+ FORMAT(GL_R16_SNORM, SN16, NONE, NONE, NONE, NONE, NONE, NONE, NONE),
+ FORMAT(GL_RG8_SNORM, SN8, SN8, NONE, NONE, NONE, NONE, NONE, NONE),
+ FORMAT(GL_RG16_SNORM, SN16, SN16, NONE, NONE, NONE, NONE, NONE, NONE),
+ FORMAT(GL_RGB8_SNORM, SN8, SN8, SN8, NONE, NONE, NONE, NONE, NONE),
+ FORMAT(GL_RGB16_SNORM, SN16, SN16, SN16, NONE, NONE, NONE, NONE, NONE),
+ FORMAT(GL_RGBA8_SNORM, SN8, SN8, SN8, SN8, NONE, NONE, NONE, NONE),
+ FORMAT(GL_RGBA16_SNORM, SN16, SN16, SN16, SN16, NONE, NONE, NONE, NONE),
+
/* Sized internal luminance formats, table 3.17 of the GL 3.0
* specification.
*/
diff --git a/tests/util/sized-internalformats.h b/tests/util/sized-internalformats.h
index e01c2f3..6bb2747 100644
--- a/tests/util/sized-internalformats.h
+++ b/tests/util/sized-internalformats.h
@@ -36,6 +36,7 @@ enum bits_types {
UN24,
UN16,
+ SN16,
F16,
I16,
U16,
--
1.7.10.4
More information about the Piglit
mailing list