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

Ben Holmes wrote:
> ---
>  tests/all.tests                |    1 +
>  tests/texturing/CMakeLists.txt |    1 +
>  tests/texturing/rg-copy-tex.c  |  130 
> ++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 132 insertions(+), 0 deletions(-)
>  create mode 100755 tests/texturing/rg-copy-tex.c
> 
> diff --git a/tests/all.tests b/tests/all.tests
> index e054c6f..97e766a 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -230,6 +230,7 @@ add_plain_test(texturing, 'depth-tex-modes')
>  add_plain_test(texturing, 'depth-tex-modes-glsl')
>  add_plain_test(texturing, 'depth-tex-compare')
>  add_plain_test(texturing, 'rg-draw-pixels')
> +add_plain_test(texturing, 'rg-copy-tex')
>  
>  glslparsertest = Group()
>  def add_glslparsertest(shader, result):
> diff --git a/tests/texturing/CMakeLists.txt b/tests/texturing/CMakeLists.txt
> index a580e88..c2e754f 100644
> --- a/tests/texturing/CMakeLists.txt
> +++ b/tests/texturing/CMakeLists.txt
> @@ -42,3 +42,4 @@ add_executable (depth-tex-modes-glsl depth-tex-modes-glsl.c)
>  add_executable (depth-tex-compare depth-tex-compare.c)
>  add_executable (tex-swizzle tex-swizzle.c)
>  add_executable (rg-draw-pixels rg-draw-pixels.c)
> +add_executable (rg-copy-tex rg-copy-tex.c)
> diff --git a/tests/texturing/rg-copy-tex.c b/tests/texturing/rg-copy-tex.c
> new file mode 100755
> index 0000000..de0d547
> --- /dev/null
> +++ b/tests/texturing/rg-copy-tex.c
> @@ -0,0 +1,130 @@
> +/*
> + * Copyright © 2009 Intel Corporation
> + *
> + * 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:
> + *   Ben Holmes <[email protected]>
> + */
> +
> +/*
> + * draws rgba texture, copies into GL_R8 and GL_RG8 textures and checks for
> + * correct color elements.
> + */
> +
> +#define texW 10
> +#define texH 10
> +
> +#include "piglit-util.h"
> +
> +int piglit_width = 40, piglit_height = 30;
> +int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
> +
> +static GLuint tex[3];
> +
> +void
> +piglit_init(int argc, char **argv)
> +{

        piglit_require_extension("GL_ARB_texture_rg");

> +     piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
> +
> +     glEnable(GL_TEXTURE_2D);
> +     glClearColor(0.2, 0.2, 0.2, 1.0);
> +}
> +
> +static void
> +loadTex()
> +{
> +     int height = 2;
> +     int width = 2;
> +     int i, j;
> +
> +     GLfloat texData[width][height][4];
> +     for (i=0; i < width; ++i) {
> +             for (j=0; j < height; ++j) {
> +                     if ((i+j) & 1) {
> +                             texData[i][j][0] = 1.0;
> +                             texData[i][j][1] = 1.0;
> +                             texData[i][j][2] = 1.0;
> +                             texData[i][j][3] = 1.0;
> +                     }
> +                     else {
> +                             texData[i][j][0] = 0.0;
> +                             texData[i][j][1] = 0.0;
> +                             texData[i][j][2] = 0.0;
> +                             texData[i][j][3] = 0.0;
> +                     }
> +             }
> +     }
> +
> +
> +     glGenTextures(3, tex);
> +     glBindTexture(GL_TEXTURE_2D, tex[0]);
> +     glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE);

The default state of GL_GENERATE_MIPMAP is GL_FALSE.  It seems unlikely
that there will ever be an implementation that has GL_ARB_texture_rg and
does not have GL_SGIS_generate_mipmap, but if this test were run on such
a system, this would generate a GL error.  I'd remove this line.

> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
> +     glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0,
> +                     GL_RGBA, GL_FLOAT, texData);
> +}
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +
> +     glClear(GL_COLOR_BUFFER_BIT);
> +     glBindTexture(GL_TEXTURE_2D, tex[0]);
> +     piglit_draw_rect_tex(0,0,10,10,0,0,1,1);
> +
> +     GLfloat pix[(texW/2)*(texH/2)*4];

Some C compilers don't like mixed code and declarations.  Move this to
the start of the function.

> +
> +     glBindTexture(GL_TEXTURE_2D, tex[1]);
> +     glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE);

Same comment as above.

> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
> +     glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_R8, 0, 5, texW/2, texH/2, 0);
> +
> +     GLboolean pass = GL_TRUE;
> +
> +     glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, pix);
> +     if(pix[1]!=0 || pix[2]!=0 || pix[3]!=1 || pix[0]!=1)
> +             pass = GL_FALSE;
> +
> +     glBindTexture(GL_TEXTURE_2D, tex[2]);
> +     glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_FALSE);

Same comment as above.

> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
> +     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
> +     glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RG8, 0, 5, texW/2, texH/2, 0);
> +
> +     glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_FLOAT, pix);
> +     if(pix[2]!=0 || pix[3]!=1 || pix[0]!=1 || pix[1]!=1)
> +             pass = GL_FALSE;
> +     else
> +             pass = pass && GL_TRUE;

Yuck!!!  Delete the whole else-statement.

> +
> +     glFinish();

There's no need for the glFinish.  It's even possible that having it
will conceal bugs.

> +     glutSwapBuffers();
> +
> +     return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;
> +}

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

iEYEARECAAYFAksGKfcACgkQX1gOwKyEAw/AkQCgoLgrHI9wzHZuBhp/sNEumm8T
DYwAnA47SjcaGU7DiwHTDTWUsk/Sxpfn
=XFMd
-----END PGP SIGNATURE-----

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Mesa3d-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mesa3d-dev

Reply via email to