[Piglit] [PATCH 2/2] util: Aggregate identical GL/GLES2 versions of some functions

Ian Romanick idr at freedesktop.org
Thu Apr 28 11:55:27 PDT 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/27/2011 01:10 PM, chad at chad-versace.us wrote:
> From: Chad Versace <chad.versace at intel.com>
> 
> Remove duplicate definitions of piglit_require_extension() from
> piglit-util-{gl,gles2}.c and define it just once in piglit-util.c. Do the
> same for piglit_require_not_extension().
> 
> Signed-off-by: Chad Versace <chad.versace at intel.com>

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

It looks like some of the probe routines could also be shared.

> ---
>  tests/util/piglit-util-gl.c    |   17 ------------
>  tests/util/piglit-util-gles2.c |   56 ----------------------------------------
>  tests/util/piglit-util.c       |   17 ++++++++++++
>  3 files changed, 17 insertions(+), 73 deletions(-)
> 
> diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
> index be6bacc..1508ed9 100644
> --- a/tests/util/piglit-util-gl.c
> +++ b/tests/util/piglit-util-gl.c
> @@ -38,23 +38,6 @@
>  
>  GLint piglit_ARBfp_pass_through = 0;
>  
> -void piglit_require_extension(const char *name)
> -{
> -	if (!piglit_is_extension_supported(name)) {
> -		printf("Test requires %s\n", name);
> -		piglit_report_result(PIGLIT_SKIP);
> -		exit(1);
> -	}
> -}
> -
> -void piglit_require_not_extension(const char *name)
> -{
> -	if (piglit_is_extension_supported(name)) {
> -		piglit_report_result(PIGLIT_SKIP);
> -		exit(1);
> -	}
> -}
> -
>  /**
>   * Read a pixel from the given location and compare its RGBA value to the
>   * given expected values.
> diff --git a/tests/util/piglit-util-gles2.c b/tests/util/piglit-util-gles2.c
> index 2e3af69..ccc14da 100644
> --- a/tests/util/piglit-util-gles2.c
> +++ b/tests/util/piglit-util-gles2.c
> @@ -35,62 +35,6 @@
>  
>  #include "piglit-util.h"
>  
> -int
> -piglit_extension_supported(const char *name)
> -{
> -	static const GLubyte *extensions = NULL;
> -	const GLubyte *start;
> -	GLubyte *where, *terminator;
> -
> -	/* Extension names should not have spaces. */
> -	where = (GLubyte *) strchr(name, ' ');
> -	if (where || *name == '\0')
> -		return 0;
> -
> -	if (!extensions) {
> -		extensions = glGetString(GL_EXTENSIONS);
> -	}
> -	/* It takes a bit of care to be fool-proof about parsing the
> -	OpenGL extensions string.  Don't be fooled by sub-strings,
> -	etc. */
> -	start = extensions;
> -	for (;;) {
> -		/* If your application crashes in the strstr routine below,
> -		you are probably calling glutExtensionSupported without
> -		having a current window.  Calling glGetString without
> -		a current OpenGL context has unpredictable results.
> -		Please fix your program. */
> -		where = (GLubyte *) strstr((const char *) start, name);
> -		if (!where)
> -			break;
> -		terminator = where + strlen(name);
> -		if (where == start || *(where - 1) == ' ') {
> -			if (*terminator == ' ' || *terminator == '\0') {
> -				return 1;
> -			}
> -		}
> -		start = terminator;
> -	}
> -	return 0;
> -}
> -
> -void piglit_require_extension(const char *name)
> -{
> -	if (!piglit_extension_supported(name)) {
> -		printf("Test requires %s\n", name);
> -		piglit_report_result(PIGLIT_SKIP);
> -		exit(1);
> -	}
> -}
> -
> -void piglit_require_not_extension(const char *name)
> -{
> -	if (piglit_extension_supported(name)) {
> -		piglit_report_result(PIGLIT_SKIP);
> -		exit(1);
> -	}
> -}
> -
>  /**
>   * Read a pixel from the given location and compare its RGBA value to the
>   * given expected values.
> diff --git a/tests/util/piglit-util.c b/tests/util/piglit-util.c
> index 0f58de1..6227dd3 100644
> --- a/tests/util/piglit-util.c
> +++ b/tests/util/piglit-util.c
> @@ -133,6 +133,23 @@ bool piglit_is_extension_supported(const char *name)
>  	return found;
>  }
>  
> +void piglit_require_extension(const char *name)
> +{
> +	if (!piglit_is_extension_supported(name)) {
> +		printf("Test requires %s\n", name);
> +		piglit_report_result(PIGLIT_SKIP);
> +		exit(1);
> +	}
> +}
> +
> +void piglit_require_not_extension(const char *name)
> +{
> +	if (piglit_is_extension_supported(name)) {
> +		piglit_report_result(PIGLIT_SKIP);
> +		exit(1);
> +	}
> +}
> +
>  /* These texture coordinates should have 1 or -1 in the major axis selecting
>   * the face, and a nearly-1-or-negative-1 value in the other two coordinates
>   * which will be used to produce the s,t values used to sample that face's

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAk25uB8ACgkQX1gOwKyEAw+lwgCfaEHNzhikua61nCjJBFOOe+jr
py8An28TC7/c5PdCm0kg9KoyBp58JCA4
=QSzk
-----END PGP SIGNATURE-----


More information about the Piglit mailing list