I added comments and refactored the test into a newer Piglit style. This helped me diagnose some difficulties with Mesa's glGetTextureImage implementation. --- .../getteximage-invalid-format-for-packed-type.c | 105 +++++++++++++-------- 1 file changed, 64 insertions(+), 41 deletions(-)
diff --git a/tests/spec/ext_packed_float/getteximage-invalid-format-for-packed-type.c b/tests/spec/ext_packed_float/getteximage-invalid-format-for-packed-type.c index 05fa006..c030c1c 100644 --- a/tests/spec/ext_packed_float/getteximage-invalid-format-for-packed-type.c +++ b/tests/spec/ext_packed_float/getteximage-invalid-format-for-packed-type.c @@ -24,19 +24,22 @@ */ /** - * file tests/spec/ext_packed_float/getteximage-invalid-format-for-packed-type.c - * test with some invalid type when the format is not GL_RGB. + * @file ext_packed_float/getteximage-invalid-format-for-packed-type.c * - * Page 262 (page 282 of the PDF) of the OpenGL 4.2 Compatibility - * Profile spec says: + * Section 8.4.4.2 Special Interpretations in Section 8.4 Pixel Rectangles of + * the OpenGL 4.5 core spec (30.10.2014) says: * - * "The number of components per packed pixel is fixed by the - * type, and must match the number of components per group - * indicated by the format parameter, as listed in table 3.8. - * The error INVALID_OPERATION is generated by any command - * processing pixel rectangles if a mismatch occurs." + * "A type matching one of the types in table 8.5 is a special case in + * which all the components of each group are packed into a single + * unsigned byte, unsigned short, or unsigned int, depending on the + * type.... + * The number of components per packed pixel is fixed by the type, and + * must match the number of components per group indicated by the format + * parameter, as listed in table 8.5. + * An INVALID_OPERATION error is generated by any command + * processing pixel rectangles if a mismatch occurs." * - * Table 3.8 says: + * Table 8.5 Packed pixel formats: * *"type Parameter Token Name ... Matching Pixel Formats" * UNSIGNED_BYTE_3_3_2 RGB, RGB_INTEGER @@ -60,8 +63,8 @@ * UNSIGNED_INT_2_10_10_10_REV RGBA, BGRA, RGBA_INTEGER, * BGRA_INTEGER * UNSIGNED_INT_24_8 DEPTH_STENCIL - * UNSIGNED_INT_10F_11F_11F_REV RGB, RGB_INTEGER - * UNSIGNED_INT_5_9_9_9_REV RGB, RGB_INTEGER + * UNSIGNED_INT_10F_11F_11F_REV RGB + * UNSIGNED_INT_5_9_9_9_REV RGB * FLOAT_32_UNSIGNED_INT_24_8_REV DEPTH_STENCIL" * * @@ -77,6 +80,16 @@ PIGLIT_GL_TEST_CONFIG_BEGIN PIGLIT_GL_TEST_CONFIG_END +/* For simplicity, we are only testing the following types: */ +static const GLenum testedTypes[] = { + GL_UNSIGNED_BYTE_3_3_2, + GL_UNSIGNED_BYTE_2_3_3_REV, + GL_UNSIGNED_SHORT_5_6_5, + GL_UNSIGNED_SHORT_5_6_5_REV, + GL_UNSIGNED_INT_10F_11F_11F_REV, +}; + +/* As Table 8.5 states, our testedTypes[] only work with GL_RGB below. */ static const GLenum formatTypes[] = { GL_RGBA, GL_RGB, @@ -88,44 +101,54 @@ static const GLenum formatTypes[] = { GL_LUMINANCE_ALPHA, }; -static const GLenum testedTypes[] = { - GL_UNSIGNED_BYTE_3_3_2, - GL_UNSIGNED_BYTE_2_3_3_REV, - GL_UNSIGNED_SHORT_5_6_5, - GL_UNSIGNED_SHORT_5_6_5_REV, - GL_UNSIGNED_INT_10F_11F_11F_REV, -}; - +void +piglit_init(int argc, char **argv) +{ + piglit_require_extension("GL_EXT_packed_float"); +} enum piglit_result -piglit_display(void) +subtest(GLenum format, GLenum type) { - return PIGLIT_FAIL; -} + GLfloat pxBuffer[4]; + enum piglit_result result; + glGetTexImage(GL_TEXTURE_2D, 0, format, type, pxBuffer); + if (format == GL_RGB) { + if (!piglit_check_gl_error(GL_NO_ERROR)) + result = PIGLIT_FAIL; + else + result = PIGLIT_PASS; + } + else { + if (!piglit_check_gl_error(GL_INVALID_OPERATION)) + result = PIGLIT_FAIL; + else + result = PIGLIT_PASS; + } -void -piglit_init(int argc, char **argv) + piglit_report_subtest_result(result, "%s, %s", + piglit_get_gl_enum_name(type), + piglit_get_gl_enum_name(format)); + + return result; +} + +enum piglit_result +piglit_display(void) { - long rcvError, expError = GL_NO_ERROR; - GLfloat pxBuffer[4]; int i, j; - - piglit_require_extension("GL_EXT_packed_float"); + enum piglit_result result = PIGLIT_PASS; + enum piglit_result subtest_result; for (j = 0; j < ARRAY_SIZE(testedTypes); j++) { - for (i = 0; i< ARRAY_SIZE(formatTypes); i++) { - glGetTexImage(GL_TEXTURE_2D, 0, formatTypes[i], - testedTypes[j], pxBuffer); - rcvError = glGetError(); - if (formatTypes[i] == GL_RGB) - expError = GL_NO_ERROR; - else - expError = GL_INVALID_OPERATION; - - if (rcvError != expError) - piglit_report_result(PIGLIT_FAIL); + for (i = 0; i < ARRAY_SIZE(formatTypes); i++) { + subtest_result = subtest(formatTypes[i], + testedTypes[j]); + if (subtest_result != PIGLIT_PASS) + result = PIGLIT_FAIL; } } - piglit_report_result(PIGLIT_PASS); + + return result; } -- 2.1.0 _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/piglit