[Mesa-dev] gl_NormalMatrix issue on Intel driver

tom fogal tfogal at sci.utah.edu
Mon Oct 17 09:28:14 PDT 2011


*ping*.  Anything to be done on my end?  -tom

tom fogal <tfogal at sci.utah.edu> writes:
> ------- =_aaaaaaaaaa0
> Content-Type: text/plain; charset="us-ascii"
> Content-ID: <27394.1318456209.1 at shigeru.sci.utah.edu>
> 
> Hi Ian, Kenneth,
> 
> Ian Romanick <idr at freedesktop.org> writes:
> > On 10/10/2011 03:30 PM, tom fogal wrote:
> > > One of our programs which relies on shaders heavily is having
> > > issues, and I have tracked it down to unexpected values in
> > > gl_NormalMatrix within the fragment shader.
> >
> > I think we could make a more general piglit test the reproduce this
> > sort of failure.
> 
> Attached is a new patch against piglit master.  I took the approach of
> generating the shader instead of uniforms, because I perceived it to be
> easier to specify .x, .y, and .z as the gl_NormalMatrix vector element.
> 
> > > Is this a known issue?  Any workarounds available?  Anything else I
> > > could do to help debug?
> >
> > Yikes!  A *lot* has changed in the fragment shader back-end for i965
> > since 7.10.2.  Have you at least tried 7.10.3?  7.11?
> 
> I've compiled Mesa master (983fa4) and enabled it (thanks for the help,
> Kenneth!) and I can reproduce it there.
> 
> The attached piglit test succeeds with: the nvidia binary blob,
> and with both versions of Mesa (7.10.2 and master-983fa4) when
> LIBGL_ALWAYS_SOFTWARE is set to 1.  It fails on both versions of Mesa
> when software mode is disabled.
> 
> What else can I do to help?
> 
> Thanks,
> 
> -tom
> 
> 
> ------- =_aaaaaaaaaa0
> Content-Type: text/x-diff; charset="us-ascii"
> Content-ID: <27394.1318456209.2 at shigeru.sci.utah.edu>
> Content-Description: 0001-Add-a-test-program-for-gl_NormalMatrix.patch
> Content-Transfer-Encoding: quoted-printable
> 
> =46rom d007b5a25bf6dbcc44beb29c689460d198f9f63b Mon Sep 17 00:00:00 2001
> From: Tom Fogal <tfogal at alumni.unh.edu>
> Date: Wed, 12 Oct 2011 15:18:28 -0600
> Subject: [PATCH] Add a test program for gl_NormalMatrix.
> 
> ---
>  tests/all.tests                      |    1 +
>  tests/shaders/CMakeLists.gl.txt      |    1 +
>  tests/shaders/glsl-fs-normalmatrix.c |  139 +++++++++++++++++++++++++++++=
> +++++
>  3 files changed, 141 insertions(+), 0 deletions(-)
>  create mode 100644 tests/shaders/glsl-fs-normalmatrix.c
> 
> diff --git a/tests/all.tests b/tests/all.tests
> index ee46be2..1a9bb11 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -386,6 +386,7 @@ add_plain_test(shaders, 'glsl-fs-loop')
>  add_plain_test(shaders, 'glsl-fs-loop-nested')
>  add_plain_test(shaders, 'glsl-fs-mix')
>  add_plain_test(shaders, 'glsl-fs-mix-constant')
> +add_plain_test(shaders, 'glsl-fs-normalmatrix')
>  add_plain_test(shaders, 'glsl-fs-pointcoord')
>  add_plain_test(shaders, 'glsl-fs-raytrace-bug27060')
>  add_plain_test(shaders, 'glsl-fs-sampler-numbering')
> diff --git a/tests/shaders/CMakeLists.gl.txt b/tests/shaders/CMakeLists.gl=
> .txt
> index d0e3005..c21432f 100644
> --- a/tests/shaders/CMakeLists.gl.txt
> +++ b/tests/shaders/CMakeLists.gl.txt
> @@ -80,6 +80,7 @@ add_executable (glsl-fs-loop glsl-fs-loop.c)
>  add_executable (glsl-fs-loop-nested glsl-fs-loop-nested.c)
>  add_executable (glsl-fs-mix glsl-fs-mix.c)
>  add_executable (glsl-fs-mix-constant glsl-fs-mix-constant.c)
> +add_executable (glsl-fs-normalmatrix glsl-fs-normalmatrix.c)
>  IF (NOT MSVC)
>  	add_executable (glsl-fs-raytrace-bug27060 glsl-fs-raytrace-bug27060.c)
>  ENDIF (NOT MSVC)
> diff --git a/tests/shaders/glsl-fs-normalmatrix.c b/tests/shaders/glsl-fs-=
> normalmatrix.c
> new file mode 100644
> index 0000000..f36b0ef
> --- /dev/null
> +++ b/tests/shaders/glsl-fs-normalmatrix.c
> @@ -0,0 +1,139 @@
> +/*
> + * Permission is hereby granted, free of charge, to any person obtaining =
> a
> + * copy of this software and associated documentation files (the "Softwar=
> e"),
> + * to deal in the Software without restriction, including without limitat=
> ion
> + * the rights to use, copy, modify, merge, publish, distribute, sublicens=
> e,
> + * 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 n=
> ext
> + * paragraph) shall be included in all copies or substantial portions of =
> the
> + * Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRES=
> S OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILIT=
> Y,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHA=
> LL
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR O=
> THER
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISIN=
> G
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DE=
> ALINGS
> + * IN THE SOFTWARE.
> + *
> + * Authors:
> + *    Tom Fogal
> + *
> + */
> +
> +/** @file glsl-fs-normalmatrix.c
> + *
> + * Tests gl_NormalMatrix for appropriate initial values.
> + */
> +
> +#include "piglit-util.h"
> +
> +int piglit_width =3D 100, piglit_height =3D 100;
> +int piglit_window_mode =3D GLUT_RGB | GLUT_DOUBLE;
> +
> +static const char vert[] =3D {
> +	"void main() {\n"
> +	"  gl_Position =3D ftransform();\n"
> +	"}\n"
> +};
> +/* Creates a fragment shader which colors everything red if
> + *   gl_NormalMatrix[elem].element
> + * is between 'low' and 'high', otherwise everything is green.
> + * The returned string is dynamically allocated and must be free'd by the
> + * caller. */
> +static char* generate_fs(double low, double high, unsigned elem, char ele=
> ment)
> +{
> +	char* shader =3D calloc(1, 1024);
> +	char* tmp =3D calloc(1, 512); /* for intermediate/appends. */
> +
> +	snprintf(shader, 1024, "void main(void) {\n");
> +	snprintf(tmp, 512,
> +					 "  if(%f <=3D gl_NormalMatrix[%u].%c &
> & gl_NormalMatrix[%u].%c <=3D=
>  %f)",
> +					 low, elem, element, elem, element, hig
> h);
> +	strncat(shader, tmp, 512);
> +	strncat(shader, " {\n", 512);
> +	strcat(shader, "    gl_FragColor =3D vec4(1.0, 0.0, 0.0, 0.05);\n");
> +	strcat(shader, "  } else {\n");
> +	strcat(shader, "    gl_FragColor =3D vec4(0.0, 1.0, 0.0, 0.05);\n");
> +	strcat(shader, "  }\n");
> +	strcat(shader, "}\n");
> +
> +	free(tmp);
> +	return shader;
> +}
> +static int test(double low, double high, unsigned elem, char element);
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +	GLboolean pass =3D GL_TRUE;
> +
> +	glClearColor(0.0, 0.0, 0.0, 0.0);
> +	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
> +	glMatrixMode(GL_MODELVIEW);
> +	glLoadIdentity();
> +
> +	pass &=3D test(0.99,  1.0,   0, 'x');
> +	pass &=3D test(0.0,   0.001, 0, 'y');
> +	pass &=3D test(0.0,   0.001, 0, 'z');
> +	pass &=3D test(0.0,   0.001, 1, 'x');
> +	pass &=3D test(0.999, 1.0,   1, 'y');
> +	pass &=3D test(0.0,   0.001, 1, 'z');
> +	pass &=3D test(0.0,   0.001, 2, 'x');
> +	pass &=3D test(0.0,   0.0,   2, 'y');
> +	pass &=3D test(0.999, 1.0,   2, 'z');
> +
> +	glutSwapBuffers();
> +
> +	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> +
> +static int test(double low, double high, unsigned elem, char element)
> +{
> +	GLint vs, fs, prog;
> +	float color[] =3D {1.0, 0.0, 0.0, 0.0};
> +	char* shader;
> +	int retval;
> +
> +	vs =3D piglit_compile_shader_text(GL_VERTEX_SHADER, vert);
> +	shader =3D generate_fs(low, high, elem, element);
> +#ifdef GLSL_DEBUG
> +	printf("generated shader:\n%s\n", shader);
> +#endif
> +	printf("test: %g <=3D gl_NormalMatrix[%u].%c <=3D %g\n", low, elem, ele
> m=
> ent,
> +	       high);
> +	fs =3D piglit_compile_shader_text(GL_FRAGMENT_SHADER, shader);
> +	prog =3D piglit_link_simple_program(vs, fs);
> +	glUseProgram(prog);
> +	free(shader);
> +
> +	piglit_draw_rect(0,0, 20,20);
> +	glutSwapBuffers();
> +	retval =3D piglit_probe_pixel_rgb(5,5, color);
> +
> +	/* clean up shaders. */
> +	glUseProgram(0);
> +	glDetachShader(prog, vs);
> +	glDetachShader(prog, fs);
> +	glDeleteProgram(prog);
> +
> +	return retval;
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +	/* Set up projection matrix so we can just draw using window
> +	 * coordinates.
> +	 */
> +	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
> +
> +	if (!GLEW_VERSION_2_0) {
> +		printf("Requires OpenGL 2.0\n");
> +		piglit_report_result(PIGLIT_SKIP);
> +	}
> +	piglit_require_vertex_shader();
> +	piglit_require_fragment_shader();
> +}
> -- =
> 
> 1.7.3.4
> 
> 
> ------- =_aaaaaaaaaa0
> Content-Type: text/plain; charset="us-ascii"
> MIME-Version: 1.0
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 
> ------- =_aaaaaaaaaa0--


More information about the mesa-dev mailing list