[Piglit] [PATCH 05/12] Port texture env test from Glean to Piglit
Note: 3 texture environment functions (modulate, decal and blend) were introduces with OpenGL 1.0. GL 1.1 and 1.3 added the replace and add functions, respectively. As this test tests all 5 functions it is classified as OpenGL 1.3. --- tests/all.py| 1 + tests/spec/gl-1.3/CMakeLists.gl.txt | 1 + tests/spec/gl-1.3/texture-env.c | 528 3 files changed, 530 insertions(+) create mode 100644 tests/spec/gl-1.3/texture-env.c diff --git a/tests/all.py b/tests/all.py index 7754dbe..48b8a51 100644 --- a/tests/all.py +++ b/tests/all.py @@ -1116,6 +1116,7 @@ with profile.test_list.group_manager( grouptools.join('spec', '!opengl 1.3')) as g: g(['texunits']) g(['tex-border-1']) +g(['gl-1.3-texture-env']) g(['tex3d-depth1']) with profile.test_list.group_manager( diff --git a/tests/spec/gl-1.3/CMakeLists.gl.txt b/tests/spec/gl-1.3/CMakeLists.gl.txt index 607d2c1..8eaa94d 100644 --- a/tests/spec/gl-1.3/CMakeLists.gl.txt +++ b/tests/spec/gl-1.3/CMakeLists.gl.txt @@ -9,5 +9,6 @@ link_libraries ( ) piglit_add_executable (gl-1.3-alpha_to_coverage_nop alpha_to_coverage_nop.c) +piglit_add_executable (gl-1.3-texture-env texture-env.c) # vim: ft=cmake: diff --git a/tests/spec/gl-1.3/texture-env.c b/tests/spec/gl-1.3/texture-env.c new file mode 100644 index 000..cffeadc --- /dev/null +++ b/tests/spec/gl-1.3/texture-env.c @@ -0,0 +1,528 @@ +/* + * Copyright (C) 1999 Allen Akin All Rights Reserved. + * + * 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 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 ALLEN AKIN 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 tex-env.c: Test the basic texture env modes + * Author: Brian Paul (bri...@valinux.com) April 2001 + * + * Test procedure: + * Setup a texture with 81 columns of unique RGBA colors, 3 texels each. + * Draw a 81 uniquely-colored flat-shaded quads as wide horizontal bands, + * with the above texture. This makes a matrix of 81*81 colored squares + * for which we test that the current texture environment mode and texture + * format produced the correct color. + * Finally, we blend over a gray background in order to verify that the + * post-texture alpha value is correct. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 13; + config.window_visual = PIGLIT_GL_VISUAL_RGBA; + config.khr_no_error_support = PIGLIT_NO_ERRORS; + config.window_width = 256; + config.window_height = 256; + +PIGLIT_GL_TEST_CONFIG_END + +#define BLEND_WITH_BACKGROUND 1 + +#define COLORS (3 * 3 * 3 * 3) + +static float colors[COLORS][4]; + +static float bg_color[4] = {0.5, 0.5, 0.5, 0.5}; + +static const GLenum format_enums[] = { + GL_ALPHA, + GL_LUMINANCE, + GL_LUMINANCE_ALPHA, + GL_INTENSITY, + GL_RGB, + GL_RGBA +}; + +static const GLenum env_mode_enums[] = { + GL_REPLACE, + GL_MODULATE, + GL_DECAL, + GL_BLEND, + GL_ADD +}; + +/* Compute expected texenv result given the texture env mode, the texture + * base format, texture color, fragment color, and texture env color. + * This also blends the result with the background color if that option + * is enabled (see above). */ +static void +compute_expected_color(GLenum env_mode, GLenum tex_format, + const float tex_color[4], const float frag_color[4], + const float env_color[4], float result[4]) +{ + switch (env_mode) { + case GL_REPLACE: + switch (tex_format) { + case GL_ALPHA: + result[0] = frag_color[0]; + result[1] = frag_color[1]; + result[2] = frag_color[2]; + result[3] = tex_color[3]; /* alpha */ + break; + case GL_LUMINANCE: + result[0] = tex_color[0]; /* lum */ + result[1] = tex_color[0]; +
Re: [Piglit] [PATCH 05/12] Port texture env test from Glean to Piglit
On 2017-11-14 23:58, Brian Paul wrote: > I'm getting a few compiler warnings from this test: > > /home/brianp/piglit/tests/spec/gl-1.3/texture-env.c: In function > ‘piglit_display’: > /home/brianp/piglit/tests/spec/gl-1.3/texture-env.c:474:17: warning: > passing argument 4 of ‘matrix_test’ from incompatible pointer type > COLORS, colors, > ^ > /home/brianp/piglit/tests/spec/gl-1.3/texture-env.c:384:1: note: > expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’ > matrix_test(GLenum env_mode, GLenum tex_format, int num_colors, > ^ > /home/brianp/piglit/tests/spec/gl-1.3/texture-env.c:483:8: warning: > passing argument 4 of ‘matrix_test’ from incompatible pointer type > colors, colors[0])) { > ^ > /home/brianp/piglit/tests/spec/gl-1.3/texture-env.c:384:1: note: > expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’ > matrix_test(GLenum env_mode, GLenum tex_format, int num_colors, > ^ > > Can you try to fix those? This revised patch set should silence those warnings. Sorry for the noisy patch the compilers I previously used didn't warn about this conversion. Fabian ___ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit
Re: [Piglit] [PATCH 05/12] Port texture env test from Glean to Piglit
I'm getting a few compiler warnings from this test: /home/brianp/piglit/tests/spec/gl-1.3/texture-env.c: In function ‘piglit_display’: /home/brianp/piglit/tests/spec/gl-1.3/texture-env.c:474:17: warning: passing argument 4 of ‘matrix_test’ from incompatible pointer type COLORS, colors, ^ /home/brianp/piglit/tests/spec/gl-1.3/texture-env.c:384:1: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’ matrix_test(GLenum env_mode, GLenum tex_format, int num_colors, ^ /home/brianp/piglit/tests/spec/gl-1.3/texture-env.c:483:8: warning: passing argument 4 of ‘matrix_test’ from incompatible pointer type colors, colors[0])) { ^ /home/brianp/piglit/tests/spec/gl-1.3/texture-env.c:384:1: note: expected ‘const float (*)[4]’ but argument is of type ‘float (*)[4]’ matrix_test(GLenum env_mode, GLenum tex_format, int num_colors, ^ Can you try to fix those? -Brian On 11/14/2017 02:47 PM, Fabian Bieler wrote: Note: 3 texture environment functions (modulate, decal and blend) were introduces with OpenGL 1.0. GL 1.1 and 1.3 added the replace and add functions, respectively. As this test tests all 5 functions it is classified as OpenGL 1.3. --- tests/all.py| 1 + tests/spec/gl-1.3/CMakeLists.gl.txt | 1 + tests/spec/gl-1.3/texture-env.c | 526 3 files changed, 528 insertions(+) create mode 100644 tests/spec/gl-1.3/texture-env.c diff --git a/tests/all.py b/tests/all.py index 7754dbe..48b8a51 100644 --- a/tests/all.py +++ b/tests/all.py @@ -1116,6 +1116,7 @@ with profile.test_list.group_manager( grouptools.join('spec', '!opengl 1.3')) as g: g(['texunits']) g(['tex-border-1']) +g(['gl-1.3-texture-env']) g(['tex3d-depth1']) with profile.test_list.group_manager( diff --git a/tests/spec/gl-1.3/CMakeLists.gl.txt b/tests/spec/gl-1.3/CMakeLists.gl.txt index 607d2c1..8eaa94d 100644 --- a/tests/spec/gl-1.3/CMakeLists.gl.txt +++ b/tests/spec/gl-1.3/CMakeLists.gl.txt @@ -9,5 +9,6 @@ link_libraries ( ) piglit_add_executable (gl-1.3-alpha_to_coverage_nop alpha_to_coverage_nop.c) +piglit_add_executable (gl-1.3-texture-env texture-env.c) # vim: ft=cmake: diff --git a/tests/spec/gl-1.3/texture-env.c b/tests/spec/gl-1.3/texture-env.c new file mode 100644 index 000..7b43507 --- /dev/null +++ b/tests/spec/gl-1.3/texture-env.c @@ -0,0 +1,526 @@ +/* + * Copyright (C) 1999 Allen Akin All Rights Reserved. + * + * 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 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 ALLEN AKIN 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 tex-env.c: Test the basic texture env modes + * Author: Brian Paul (bri...@valinux.com) April 2001 + * + * Test procedure: + * Setup a texture with 81 columns of unique RGBA colors, 3 texels each. + * Draw a 81 uniquely-colored flat-shaded quads as wide horizontal bands, + * with the above texture. This makes a matrix of 81*81 colored squares + * for which we test that the current texture environment mode and texture + * format produced the correct color. + * Finally, we blend over a gray background in order to verify that the + * post-texture alpha value is correct. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 13; + config.window_visual = PIGLIT_GL_VISUAL_RGBA; + config.khr_no_error_support = PIGLIT_NO_ERRORS; + config.window_width = 256; + config.window_height = 256; + +PIGLIT_GL_TEST_CONFIG_END + +#define BLEND_WITH_BACKGROUND 1 + +#define COLORS (3 * 3 * 3 * 3) + +static float colors[COLORS][4]; + +static float bg_color[4] = {0.5, 0.5, 0.5, 0.5}; + +static const GLenum format_enums[] = { + GL_ALPHA, + GL_LUMINANCE, + GL_LUMINANCE_ALPHA, + GL_INTENSITY, + GL_RGB, + GL_RGBA +}; + +static const GLenum env_mode_enums[] = { + GL_REPLACE, + GL_MODULATE, + GL_DECAL, + GL_BLEND, + GL
[Piglit] [PATCH 05/12] Port texture env test from Glean to Piglit
Note: 3 texture environment functions (modulate, decal and blend) were introduces with OpenGL 1.0. GL 1.1 and 1.3 added the replace and add functions, respectively. As this test tests all 5 functions it is classified as OpenGL 1.3. --- tests/all.py| 1 + tests/spec/gl-1.3/CMakeLists.gl.txt | 1 + tests/spec/gl-1.3/texture-env.c | 526 3 files changed, 528 insertions(+) create mode 100644 tests/spec/gl-1.3/texture-env.c diff --git a/tests/all.py b/tests/all.py index 7754dbe..48b8a51 100644 --- a/tests/all.py +++ b/tests/all.py @@ -1116,6 +1116,7 @@ with profile.test_list.group_manager( grouptools.join('spec', '!opengl 1.3')) as g: g(['texunits']) g(['tex-border-1']) +g(['gl-1.3-texture-env']) g(['tex3d-depth1']) with profile.test_list.group_manager( diff --git a/tests/spec/gl-1.3/CMakeLists.gl.txt b/tests/spec/gl-1.3/CMakeLists.gl.txt index 607d2c1..8eaa94d 100644 --- a/tests/spec/gl-1.3/CMakeLists.gl.txt +++ b/tests/spec/gl-1.3/CMakeLists.gl.txt @@ -9,5 +9,6 @@ link_libraries ( ) piglit_add_executable (gl-1.3-alpha_to_coverage_nop alpha_to_coverage_nop.c) +piglit_add_executable (gl-1.3-texture-env texture-env.c) # vim: ft=cmake: diff --git a/tests/spec/gl-1.3/texture-env.c b/tests/spec/gl-1.3/texture-env.c new file mode 100644 index 000..7b43507 --- /dev/null +++ b/tests/spec/gl-1.3/texture-env.c @@ -0,0 +1,526 @@ +/* + * Copyright (C) 1999 Allen Akin All Rights Reserved. + * + * 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 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 ALLEN AKIN 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 tex-env.c: Test the basic texture env modes + * Author: Brian Paul (bri...@valinux.com) April 2001 + * + * Test procedure: + * Setup a texture with 81 columns of unique RGBA colors, 3 texels each. + * Draw a 81 uniquely-colored flat-shaded quads as wide horizontal bands, + * with the above texture. This makes a matrix of 81*81 colored squares + * for which we test that the current texture environment mode and texture + * format produced the correct color. + * Finally, we blend over a gray background in order to verify that the + * post-texture alpha value is correct. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 13; + config.window_visual = PIGLIT_GL_VISUAL_RGBA; + config.khr_no_error_support = PIGLIT_NO_ERRORS; + config.window_width = 256; + config.window_height = 256; + +PIGLIT_GL_TEST_CONFIG_END + +#define BLEND_WITH_BACKGROUND 1 + +#define COLORS (3 * 3 * 3 * 3) + +static float colors[COLORS][4]; + +static float bg_color[4] = {0.5, 0.5, 0.5, 0.5}; + +static const GLenum format_enums[] = { + GL_ALPHA, + GL_LUMINANCE, + GL_LUMINANCE_ALPHA, + GL_INTENSITY, + GL_RGB, + GL_RGBA +}; + +static const GLenum env_mode_enums[] = { + GL_REPLACE, + GL_MODULATE, + GL_DECAL, + GL_BLEND, + GL_ADD +}; + +/* Compute expected texenv result given the texture env mode, the texture + * base format, texture color, fragment color, and texture env color. + * This also blends the result with the background color if that option + * is enabled (see above). */ +static void +compute_expected_color(GLenum env_mode, GLenum tex_format, + const float tex_color[4], const float frag_color[4], + const float env_color[4], float result[4]) +{ + switch (env_mode) { + case GL_REPLACE: + switch (tex_format) { + case GL_ALPHA: + result[0] = frag_color[0]; + result[1] = frag_color[1]; + result[2] = frag_color[2]; + result[3] = tex_color[3]; /* alpha */ + break; + case GL_LUMINANCE: + result[0] = tex_color[0]; /* lum */ + result[1] = tex_color[0]; +
[Piglit] [PATCH 05/12] Port texture env test from Glean to Piglit
Note: 3 texture environment functions (modulate, decal and blend) were introduces with OpenGL 1.0. GL 1.1 and 1.3 added the replace and add functions, respectively. As this test tests all 5 functions it is classified as OpenGL 1.3. --- tests/all.py| 1 + tests/spec/gl-1.3/CMakeLists.gl.txt | 1 + tests/spec/gl-1.3/texture-env.c | 526 3 files changed, 528 insertions(+) create mode 100644 tests/spec/gl-1.3/texture-env.c diff --git a/tests/all.py b/tests/all.py index 3fd1153..3142ad2 100644 --- a/tests/all.py +++ b/tests/all.py @@ -1037,6 +1037,7 @@ with profile.test_list.group_manager( grouptools.join('spec', '!opengl 1.3')) as g: g(['texunits']) g(['tex-border-1']) +g(['gl-1.3-texture-env']) g(['tex3d-depth1']) with profile.test_list.group_manager( diff --git a/tests/spec/gl-1.3/CMakeLists.gl.txt b/tests/spec/gl-1.3/CMakeLists.gl.txt index 607d2c1..8eaa94d 100644 --- a/tests/spec/gl-1.3/CMakeLists.gl.txt +++ b/tests/spec/gl-1.3/CMakeLists.gl.txt @@ -9,5 +9,6 @@ link_libraries ( ) piglit_add_executable (gl-1.3-alpha_to_coverage_nop alpha_to_coverage_nop.c) +piglit_add_executable (gl-1.3-texture-env texture-env.c) # vim: ft=cmake: diff --git a/tests/spec/gl-1.3/texture-env.c b/tests/spec/gl-1.3/texture-env.c new file mode 100644 index 000..7b43507 --- /dev/null +++ b/tests/spec/gl-1.3/texture-env.c @@ -0,0 +1,526 @@ +/* + * Copyright (C) 1999 Allen Akin All Rights Reserved. + * + * 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 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 ALLEN AKIN 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 tex-env.c: Test the basic texture env modes + * Author: Brian Paul (bri...@valinux.com) April 2001 + * + * Test procedure: + * Setup a texture with 81 columns of unique RGBA colors, 3 texels each. + * Draw a 81 uniquely-colored flat-shaded quads as wide horizontal bands, + * with the above texture. This makes a matrix of 81*81 colored squares + * for which we test that the current texture environment mode and texture + * format produced the correct color. + * Finally, we blend over a gray background in order to verify that the + * post-texture alpha value is correct. + */ + +#include "piglit-util-gl.h" + +PIGLIT_GL_TEST_CONFIG_BEGIN + + config.supports_gl_compat_version = 13; + config.window_visual = PIGLIT_GL_VISUAL_RGBA; + config.khr_no_error_support = PIGLIT_NO_ERRORS; + config.window_width = 256; + config.window_height = 256; + +PIGLIT_GL_TEST_CONFIG_END + +#define BLEND_WITH_BACKGROUND 1 + +#define COLORS (3 * 3 * 3 * 3) + +static float colors[COLORS][4]; + +static float bg_color[4] = {0.5, 0.5, 0.5, 0.5}; + +static const GLenum format_enums[] = { + GL_ALPHA, + GL_LUMINANCE, + GL_LUMINANCE_ALPHA, + GL_INTENSITY, + GL_RGB, + GL_RGBA +}; + +static const GLenum env_mode_enums[] = { + GL_REPLACE, + GL_MODULATE, + GL_DECAL, + GL_BLEND, + GL_ADD +}; + +/* Compute expected texenv result given the texture env mode, the texture + * base format, texture color, fragment color, and texture env color. + * This also blends the result with the background color if that option + * is enabled (see above). */ +static void +compute_expected_color(GLenum env_mode, GLenum tex_format, + const float tex_color[4], const float frag_color[4], + const float env_color[4], float result[4]) +{ + switch (env_mode) { + case GL_REPLACE: + switch (tex_format) { + case GL_ALPHA: + result[0] = frag_color[0]; + result[1] = frag_color[1]; + result[2] = frag_color[2]; + result[3] = tex_color[3]; /* alpha */ + break; + case GL_LUMINANCE: + result[0] = tex_color[0]; /* lum */ + result[1] = tex_color[0]; +