[Mesa-dev] [PATCH] glsl-fs-normalmatrix: New test program for gl_NormalMatrix.

Eric Anholt eric at anholt.net
Thu Oct 20 08:50:00 PDT 2011


On Wed, 19 Oct 2011 13:15:05 -0700, Paul Berry <stereotype441 at gmail.com> wrote:
Non-text part: multipart/alternative
> On 18 October 2011 17:33, Eric Anholt <eric at anholt.net> wrote:
> 
> > From: tom fogal <tfogal at sci.utah.edu>
> >
> > v2: lots of hacking by anholt to make it look more like a normal
> >    piglit test and make all results visible at once.
> > ---
> >  tests/all.tests                      |    1 +
> >  tests/shaders/CMakeLists.gl.txt      |    1 +
> >  tests/shaders/glsl-fs-normalmatrix.c |  166
> > ++++++++++++++++++++++++++++++++++
> >  3 files changed, 168 insertions(+), 0 deletions(-)
> >  create mode 100644 tests/shaders/glsl-fs-normalmatrix.c
> >
> > diff --git a/tests/all.tests b/tests/all.tests
> > index 0248164..89bd03d 100644
> > --- a/tests/all.tests
> > +++ b/tests/all.tests
> > @@ -396,6 +396,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_concurrent_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 3dce256..ed72b21 100644
> > --- a/tests/shaders/CMakeLists.gl.txt
> > +++ b/tests/shaders/CMakeLists.gl.txt
> > @@ -82,6 +82,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..b55a80a
> > --- /dev/null
> > +++ b/tests/shaders/glsl-fs-normalmatrix.c
> > @@ -0,0 +1,166 @@
> > +/*
> > + * 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.
> > + *
> > + * Authors:
> > + *    Tom Fogal
> > + *
> > + */
> > +
> > +/** @file glsl-fs-normalmatrix.c
> > + *
> > + * Tests gl_NormalMatrix for appropriate initial values.
> > + */
> > +
> > +#include "piglit-util.h"
> > +
> > +int piglit_width = 30, piglit_height = 30;
> > +int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
> > +
> > +static const char vert[] = {
> > +       "void main()\n"
> > +       "{\n"
> > +       "       gl_Position = ftransform();\n"
> > +       "}\n"
> > +};
> > +
> > +/* Creates a fragment shader which colors everything green if
> > + *   gl_NormalMatrix[col].row
> > + * is between 'low' and 'high', otherwise everything is red.
> > + * The returned string is dynamically allocated and must be free'd by the
> > + * caller.
> > + */
> > +static char *
> > +generate_fs(int row, int col)
> > +{
> > +       static const char *fs_template =
> > +               "void main()\n"
> > +               "{\n"
> > +               "       if (%f <= gl_NormalMatrix[%u].%c &&\n"
> > +               "           gl_NormalMatrix[%u].%c <= %f)\n"
> > +               "               gl_FragColor = vec4(0.0, 1.0, 0.0, 0.0);\n"
> > +               "       else\n"
> > +               "               gl_FragColor = vec4(1.0, 0.0, 0.0, 0.0);\n"
> > +               "}\n";
> >
> 
> I think it would be clearer to use uniforms rather than all of this string
> interpolation.  If we did that, then if I'm not mistaken, this whole test
> could be converted into a shader_runner test..

Good point.  I was thinking the string choices were important initially,
because it might have been an issue with dead uniform element
elimination, but array access of the uniform should be fine for showing
the bug.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/mesa-dev/attachments/20111020/19071718/attachment.pgp>


More information about the mesa-dev mailing list