[Piglit] [PATCH 02/13] glsl: Add program to test all shader built-in constants
Eric Anholt
eric at anholt.net
Mon Aug 26 15:34:05 PDT 2013
Ian Romanick <idr at freedesktop.org> writes:
> From: Ian Romanick <ian.d.romanick at intel.com>
>
> Using a simple text file, all shader built-in constants can be tested.
> This has several advantages over the previous methodology.
>
> 1. All of the built-in constants and their expected values are kept in
> one place per GLSL version.
>
> 2. The tests use the array-size idiom of many piglit tests which
> guarantees that the values being tested are actually contants.
>
> 3. Since the tests are not execution tests, they run much faster. The
> single top-level test can also run concurrently with other tests. The
> speed difference is trivial most of the time, but in simlation
> environments, each pixel drawn takes a very long time. You're welcome,
> Chad.
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> + parse_file(argv[1]);
> + switch (required_glsl_version) {
> + case 100:
> + config.supports_gl_core_version = 0;
> + config.supports_gl_compat_version = 0;
> + config.supports_gl_es_version = 20;
> + break;
> + case 110:
> + case 120:
> + config.supports_gl_core_version = 0;
> + config.supports_gl_compat_version = 10;
> + break;
> + case 130:
> + config.supports_gl_core_version = 31;
> + config.supports_gl_compat_version = 21;
> + break;
> + case 140:
> + config.supports_gl_core_version = 31;
> + config.supports_gl_compat_version = 31;
> + break;
> + case 150:
> + config.supports_gl_core_version = 32;
> + config.supports_gl_compat_version = 32;
> + break;
> + case 300:
> + config.supports_gl_core_version = 0;
> + config.supports_gl_compat_version = 0;
> + config.supports_gl_es_version = 30;
> + break;
> + case 330:
> + case 400:
> + case 410:
> + case 420:
> + case 430:
> + case 440:
> + config.supports_gl_core_version = required_glsl_version / 10;
> + config.supports_gl_compat_version = required_glsl_version / 10;
> + break;
> + }
This seems like it should follow glslparsertest's lead and be using
required_gl_version_from_glsl_version(), at least. There may be even
more sharing available between these 3 test runners.
> + line = (char *) eat_whitespace(line);
> +
> + if (strncmp("gl_Max", line, 6) != 0) {
Might pull string_match() into parser-utils.h, too. Counting characters
makes me cringe.
> + tests[num_tests].name = line;
> +
> + line = (char *) eat_text(line);
> + line[0] = '\0';
> + line++;
> +
> + line = (char *) eat_whitespace(line);
> +
> + tests[num_tests].minimum = strtol(line, &endptr, 0);
> + if (endptr == line) {
> + char bad_number[32];
> +
> + strncpy(bad_number, line, sizeof(bad_number));
> + endptr = strchrnul(bad_number, '\n');
> + endptr[0] = '\0';
> +
> + fprintf(stderr,
> + "Invalid built-in constant value \"%s\".\n",
> + bad_number);
> + piglit_report_result(PIGLIT_FAIL);
I was expecting the file format to want lines of the form you'd get from
copy and pasting from the spec, then I found that the 3.30 spec has them
written in the form of a table and the paste result is a mess. So, meh.
> +
> + /* If both compilation phases passed, try to link the shaders
> + * together.
> + */
> + if (subtest_pass) {
> + GLuint prog = glCreateProgram();
> +
trailing whitespace
> + glAttachShader(prog, test_vs);
> + glAttachShader(prog, test_fs);
> +
> + if (test_gs != 0)
> + glAttachShader(prog, test_gs);
> +
> + glLinkProgram(prog);
> + subtest_pass = !!piglit_link_check_status(prog);
> +
> + glDeleteProgram(prog);
> + }
I'm curious, what are we testing for here? When would the compile
succeed but link fail?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130826/1a4088a5/attachment-0001.pgp>
More information about the Piglit
mailing list