[Piglit] [PATCH 1/2] Add usage information to getteximage-targets
Emil Velikov
emil.l.velikov at gmail.com
Sun Apr 12 06:04:45 PDT 2015
On 11 April 2015 at 00:11, Anuj Phogat <anuj.phogat at gmail.com> wrote:
> Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
> ---
> tests/all.py | 8 +--
> tests/texturing/getteximage-targets.c | 121 ++++++++++++++++++++++------------
> 2 files changed, 82 insertions(+), 47 deletions(-)
>
> diff --git a/tests/all.py b/tests/all.py
> index 4d47c4c..c1fac8f 100755
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -3035,10 +3035,10 @@ with profile.group_manager(
> g(['s3tc-errors'])
> g(['s3tc-teximage'], run_concurrent=False)
> g(['s3tc-texsubimage'], run_concurrent=False)
> - g(['getteximage-targets', 'S3TC', '2D'])
> - g(['getteximage-targets', 'S3TC', '2D_ARRAY'])
> - g(['getteximage-targets', 'S3TC', 'CUBE'])
> - g(['getteximage-targets', 'S3TC', 'CUBE_ARRAY'])
> + g(['getteximage-targets', '2D', 'S3TC'])
> + g(['getteximage-targets', '2D_ARRAY', 'S3TC'])
> + g(['getteximage-targets', 'CUBE', 'S3TC'])
> + g(['getteximage-targets', 'CUBE_ARRAY', 'S3TC'])
> g(['compressedteximage', 'GL_COMPRESSED_SRGB_S3TC_DXT1_EXT'])
> g(['compressedteximage', 'GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT'])
> g(['compressedteximage', 'GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT'])
> diff --git a/tests/texturing/getteximage-targets.c b/tests/texturing/getteximage-targets.c
> index 03bb4f8..841ba45 100644
> --- a/tests/texturing/getteximage-targets.c
> +++ b/tests/texturing/getteximage-targets.c
> @@ -221,58 +221,93 @@ getTexImage(bool doPBO, GLenum target, GLubyte data[][IMAGE_SIZE],
> return pass;
> }
>
> +NORETURN void
> +print_usage_and_exit(char *prog_name)
> +{
> + printf("Usage: %s <target> <compression>\n"
> + " where <target> is one of:\n"
> + " 1D\n"
> + " 2D\n"
> + " 3D\n"
> + " RECT\n"
> + " CUBE\n"
> + " 1D_ARRAY\n"
> + " 2D_ARRAY\n"
> + " CUBE_ARRAY\n"
> + " where <compression> is one of:\n"
where <compression> is optional and can be one of;
> + " S3TC: Valid only with 2D* and CUBE* targets\n",
> + prog_name);
> + piglit_report_result(PIGLIT_FAIL);
> +}
> +
> void
> piglit_init(int argc, char **argv)
> {
> - int i;
> - GLenum target = GL_TEXTURE_2D;
> + int i = 1;
With the loop gone, one might as well nuke i.
> + GLenum target;
> bool pass = true;
> GLenum internalformat = GL_RGBA8;
> GLubyte data[18][IMAGE_SIZE];
> int tolerance = 0;
>
> - for (i = 1; i < argc; i++) {
> - if (strcmp(argv[i], "1D") == 0) {
> - target = GL_TEXTURE_1D;
> - }
> - if (strcmp(argv[i], "3D") == 0) {
> - target = GL_TEXTURE_3D;
> - piglit_require_gl_version(12);
> - }
> - if (strcmp(argv[i], "RECT") == 0) {
> - target = GL_TEXTURE_RECTANGLE;
> - piglit_require_extension("GL_ARB_texture_rectangle");
> - }
> - if (strcmp(argv[i], "CUBE") == 0) {
> - target = GL_TEXTURE_CUBE_MAP;
> - piglit_require_extension("GL_ARB_texture_cube_map");
> - }
> - if (strcmp(argv[i], "1D_ARRAY") == 0) {
> - target = GL_TEXTURE_1D_ARRAY;
> - piglit_require_extension("GL_EXT_texture_array");
> - }
> - if (strcmp(argv[i], "2D_ARRAY") == 0) {
> - target = GL_TEXTURE_2D_ARRAY;
> - piglit_require_extension("GL_EXT_texture_array");
> - }
> - if (strcmp(argv[i], "CUBE_ARRAY") == 0) {
> - target = GL_TEXTURE_CUBE_MAP_ARRAY;
> - piglit_require_extension("GL_ARB_texture_cube_map_array");
> - }
> - if (strcmp(argv[i], "S3TC") == 0) {
> - internalformat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
> - tolerance = 8;
> - if (!piglit_is_extension_supported("GL_EXT_texture_compression_s3tc")
> - && !piglit_is_extension_supported("GL_ANGLE_texture_compression_dxt5")) {
> - fprintf(stderr,
> - "S3TC testing requires either "
> - "GL_EXT_texture_compression_s3tc or "
> - "GL_ANGLE_texture_compression_dxt5 "
> - "extension be supported.\n");
> - piglit_report_result(PIGLIT_SKIP);
> - }
> - puts("Testing S3TC.");
> + if (argc < 2 || argc > 3)
> + print_usage_and_exit(argv[0]);
> +
> + if (strcmp(argv[i], "1D") == 0) {
> + target = GL_TEXTURE_1D;
> + }
> + else if (strcmp(argv[i], "2D") == 0) {
> + target = GL_TEXTURE_2D;
> + }
> + else if (strcmp(argv[i], "3D") == 0) {
> + target = GL_TEXTURE_3D;
> + piglit_require_gl_version(12);
> + }
> + else if (strcmp(argv[i], "RECT") == 0) {
> + target = GL_TEXTURE_RECTANGLE;
> + piglit_require_extension("GL_ARB_texture_rectangle");
> + }
> + else if (strcmp(argv[i], "CUBE") == 0) {
> + target = GL_TEXTURE_CUBE_MAP;
> + piglit_require_extension("GL_ARB_texture_cube_map");
> + }
> + else if (strcmp(argv[i], "1D_ARRAY") == 0) {
> + target = GL_TEXTURE_1D_ARRAY;
> + piglit_require_extension("GL_EXT_texture_array");
> + }
> + else if (strcmp(argv[i], "2D_ARRAY") == 0) {
> + target = GL_TEXTURE_2D_ARRAY;
> + piglit_require_extension("GL_EXT_texture_array");
> + }
> + else if (strcmp(argv[i], "CUBE_ARRAY") == 0) {
> + target = GL_TEXTURE_CUBE_MAP_ARRAY;
> + piglit_require_extension("GL_ARB_texture_cube_map_array");
> + }
> + else {
> + print_usage_and_exit(argv[0]);
> + }
> +
> + i++;
> +
> + if (argc == 3 && strcmp(argv[i], "S3TC") == 0 &&
> + (target == GL_TEXTURE_2D ||
> + target == GL_TEXTURE_2D_ARRAY ||
> + target == GL_TEXTURE_CUBE_MAP ||
> + target == GL_TEXTURE_CUBE_MAP_ARRAY)) {
> + internalformat = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT;
> + tolerance = 8;
> + if (!piglit_is_extension_supported("GL_EXT_texture_compression_s3tc")
> + && !piglit_is_extension_supported("GL_ANGLE_texture_compression_dxt5")) {
Piglit seems to be using a mix of trailing vs leading && (same story
for ||), with the former more widely used.
> + fprintf(stderr,
> + "S3TC testing requires either "
> + "GL_EXT_texture_compression_s3tc or "
> + "GL_ANGLE_texture_compression_dxt5 "
> + "extension be supported.\n");
> + piglit_report_result(PIGLIT_SKIP);
> }
> + puts("Testing S3TC.");
One could replace the puts with {f,}printf.
The last two are on the bikeshed side so feel free to ignore them :-)
With i gone, and the "<compression> is optional"
Reviewed-by: Emil Velikov <emil.l.velikov at gmail.com>
-Emil
More information about the Piglit
mailing list