[Piglit] [v8 10/13] tests/spec: EXT_image_dma_buf_import sample xrgb

Chad Versace chad.versace at linux.intel.com
Mon Aug 5 09:54:08 PDT 2013


>>>> Please fold this test into patch 9. If I recall correctly, the Piglit framework
>>>> strips all common command line args such as '-fbo' and '-auto' out of argv before
>>>> passing argv to piglit_init().
>>>
>>> It would in fact require two arguments, one for format and another boolean for
>>> telling if alpha channel is expected to be forced to 1.0. Would that be okay?
>>
>> The spec says that alpha gets forced to 1.0 if the format has no alpha channel.
>> Since that is dictated by the spec, then I think the test only needs one argument,
>> the format, because force_alpha can be deduced from the format. At least, I
>> think that should work. Am I missing something?
>>
>
> Well I was just trying to keep the test case simple without any logic knowing
> about drm-fourcc formats and if the alpha is to be treated specially for one
> and not for the other. Something on these lines:

Sounds and looks good to me. I like how you were able to capture all the drm fourcc
formats without a giant switch statement.

> +static int
> +parse_format(const char *s)
> +{
> +	if (strlen(s) != 4)
> +		return -1;
> +
> +	return (int)fourcc_code(s[0], s[1], s[2], s[3]);
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +	unsigned i;
> +
> +	piglit_require_egl_extension("EGL_EXT_image_dma_buf_import");
> +	piglit_require_extension("GL_OES_EGL_image_external");
> +
> +	for (i = 1; i < argc; i++) {
> +                static const char fmt[] = "-fmt=";
> +
> +                if (!strcmp(argv[i], "-alpha-one")) {
> +			force_alpha_to_one = true;
> +                        continue;
> +                }
> +
> +                if (strncmp(argv[i], fmt, sizeof(fmt) - 1)) {
> +			fprintf(stderr, "unknown argument %s\n", argv[i]);
> +                        continue;
> +		}
> +
> +		fourcc = parse_format(argv[i] + sizeof(fmt) - 1);
> +		if (fourcc == -1) {
> +			fprintf(stderr, "invalid format: %s\n", argv[i]);
> +			piglit_report_result(PIGLIT_SKIP);
> +		}
> +        }
> +
> +	if (fourcc == -1) {
> +		fprintf(stderr, "format not specified\n");
> +		piglit_report_result(PIGLIT_SKIP);
> +	}
> +}



More information about the Piglit mailing list