[Piglit] [PATCH] gl-1.2: Test normal rescaling with fixed function pipeline.

Brian Paul brianp at vmware.com
Thu Nov 30 00:08:44 UTC 2017


On 11/29/2017 04:28 PM, Fabian Bieler wrote:
> Set up scene with diffuse lighting and an isotropic modelview scale of 100.
> Set the light color to 1% red, 100% green, 0% blue.
> If the normal is incorectly scaled in either direction, the sampled color

"incorrectly"

> would be black or yellow, respectively, instead of green.
> ---
>   tests/all.py                        |  1 +
>   tests/spec/gl-1.2/CMakeLists.gl.txt |  1 +
>   tests/spec/gl-1.2/rescale-normal.c  | 76 +++++++++++++++++++++++++++++++++++++
>   3 files changed, 78 insertions(+)
>   create mode 100644 tests/spec/gl-1.2/rescale-normal.c
>
> diff --git a/tests/all.py b/tests/all.py
> index cf15640..155ee2a 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -1103,6 +1103,7 @@ with profile.test_list.group_manager(
>       g(['lodclamp-between'])
>       g(['lodclamp-between-max'])
>       g(['mipmap-setup'])
> +    g(['gl-1.2-rescale_normal'])
>       g(['tex-skipped-unit'])
>       g(['tex3d'])
>       g(['tex3d-maxsize'], run_concurrent=False)
> diff --git a/tests/spec/gl-1.2/CMakeLists.gl.txt b/tests/spec/gl-1.2/CMakeLists.gl.txt
> index 029c54b..ce291da 100644
> --- a/tests/spec/gl-1.2/CMakeLists.gl.txt
> +++ b/tests/spec/gl-1.2/CMakeLists.gl.txt
> @@ -8,6 +8,7 @@ link_libraries (
>   	${OPENGL_gl_LIBRARY}
>   )
>
> +piglit_add_executable (gl-1.2-rescale-normal rescale-normal.c)
>   piglit_add_executable (gl-1.2-texture-base-level texture-base-level.c)
>
>   # vim: ft=cmake:
> diff --git a/tests/spec/gl-1.2/rescale-normal.c b/tests/spec/gl-1.2/rescale-normal.c
> new file mode 100644
> index 0000000..c011018
> --- /dev/null
> +++ b/tests/spec/gl-1.2/rescale-normal.c
> @@ -0,0 +1,76 @@
> +/*
> + * Copyright © 2017 Fabian Bieler
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice (including the next
> + * paragraph) shall be included in all copies or substantial portions of the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
> + * IN THE SOFTWARE.
> + */
> +
> +/**
> + * @file rescale-normal.c:  Rescale normals with fixed function pipeline.
> + *
> + * Set up scene with diffuse lighting and an isotropic modelview scale of 100.
> + * Set the light color to 1% red, 100% green, 0% blue.
> + * If the normal is incorectly scaled in either direction, the sampled color
> + * would be black or yellow, respectively, instead of green.
> + */
> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +	config.supports_gl_compat_version = 12;
> +	config.window_visual = (PIGLIT_GL_VISUAL_RGB);

parens not needed there.  I noticed that in your other patches too, but 
not a big deal.

> +	config.khr_no_error_support = PIGLIT_NO_ERRORS;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +static const float green_with_a_smitch_of_red[] = {0.01, 1, 0, 1};

:)


> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +	piglit_draw_rect(-0.01, -0.01, 0.02, 0.02);
> +	bool pass = piglit_probe_pixel_rgb(piglit_width / 2,
> +					   piglit_height / 2,
> +					   green_with_a_smitch_of_red);
> +
> +	piglit_present_results();
> +
> +	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +	const float black[] = {0, 0, 0, 1};
> +	const float white[] = {1, 1, 1, 1};
> +
> +	glEnable(GL_LIGHTING);
> +	glEnable(GL_LIGHT0);
> +
> +	glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, black);
> +	glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, white);
> +
> +	glLightfv(GL_LIGHT0, GL_DIFFUSE, green_with_a_smitch_of_red);
> +
> +	glScalef(100.0, 100.0, 100.0);
> +	glEnable(GL_RESCALE_NORMAL);
> +
> +	glNormal3f(0, 0, 1);
> +}
>

Reviewed-by: Brian Paul <brianp at vmware.com>





More information about the Piglit mailing list