[Piglit] [PATCH 02/13] glsl: Add program to test all shader built-in constants

Ian Romanick idr at freedesktop.org
Mon Aug 26 16:44:03 PDT 2013


On 08/26/2013 03:34 PM, Eric Anholt wrote:
> 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.

I didn't know there was such a function!  I like that idea.  Although, 
that function doesn't support ES versions... hmm...

>> +		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.

Yeah, that's sensible.

>> +		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.

At least the way evince copy-and-pastes, it /almost/ works out.  This is 
what I got from 3.30:

gl_MaxVertexAttribs = 16;
gl_MaxVertexUniformComponents = 1024;
gl_MaxVaryingFloats = 60;
// Deprecated
gl_MaxVaryingComponents = 60;
// Deprecated
gl_MaxVertexOutputComponents = 64;
gl_MaxGeometryInputComponents = 64;
gl_MaxGeometryOutputComponents = 128;
gl_MaxFragmentInputComponents = 128;
gl_MaxVertexTextureImageUnits = 16;
gl_MaxCombinedTextureImageUnits = 48;
gl_MaxTextureImageUnits = 16;
gl_MaxFragmentUniformComponents = 1024;
gl_MaxDrawBuffers = 8;
gl_MaxClipDistances = 8;
gl_MaxGeometryTextureImageUnits = 16;
gl_MaxGeometryOutputVertices = 256;
gl_MaxGeometryTotalOutputComponents = 1024;
gl_MaxGeometryUniformComponents = 1024;
gl_MaxGeometryVaryingComponents = 64;

>> +
>> +		/* 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?

Many other compilers (because of some insanity with 
GL_ARB_geometry_shader4) don't check a lot of things until you link... 
including array sizes.



More information about the Piglit mailing list