On Thu, Mar 12, 2015 at 2:14 PM, Laura Ekstrand <[email protected]> wrote: > This test reproduces the cause of Mesa Bug 89526 in Piglit. While > investigating 89526, it was discovered that Piglit had no tests that created a > cube map texture without glTexStorage2D and then called glGenerateMipmap on > it. For this reason, the offending commit was upstreamed before the failure > was caught. > > This test successfully fails when commit 1ee000a is present and passes when > 1ee000a is reverted. > --- > tests/all.py | 1 + > tests/texturing/CMakeLists.gl.txt | 1 + > tests/texturing/generatemipmap-cubemap.c | 89 > ++++++++++++++++++++++++++++++++ > 3 files changed, 91 insertions(+) > create mode 100644 tests/texturing/generatemipmap-cubemap.c > > diff --git a/tests/all.py b/tests/all.py > index ad5741d..bbf9ee0 100644 > --- a/tests/all.py > +++ b/tests/all.py > @@ -1138,6 +1138,7 @@ with profile.group_manager( > g(['array-depth-roundtrip'], run_concurrent=False) > g(['depth-cube-map'], run_concurrent=False) > g(['sampler-cube-shadow'], run_concurrent=False) > + g(['generatemipmap-cubemap']) > > with profile.group_manager( > PiglitGLTest, > diff --git a/tests/texturing/CMakeLists.gl.txt > b/tests/texturing/CMakeLists.gl.txt > index b77f71f..fc5c38f 100644 > --- a/tests/texturing/CMakeLists.gl.txt > +++ b/tests/texturing/CMakeLists.gl.txt > @@ -36,6 +36,7 @@ piglit_add_executable (getteximage-simple > getteximage-simple.c) > piglit_add_executable (getteximage-luminance getteximage-luminance.c) > piglit_add_executable (getteximage-targets getteximage-targets.c) > piglit_add_executable (incomplete-texture incomplete-texture.c) > +piglit_add_executable (generatemipmap-cubemap generatemipmap-cubemap.c) > piglit_add_executable (fragment-and-vertex-texturing > fragment-and-vertex-texturing.c) > piglit_add_executable (levelclamp levelclamp.c) > piglit_add_executable (lodbias lodbias.c) > diff --git a/tests/texturing/generatemipmap-cubemap.c > b/tests/texturing/generatemipmap-cubemap.c > new file mode 100644 > index 0000000..3cfd65e > --- /dev/null > +++ b/tests/texturing/generatemipmap-cubemap.c > @@ -0,0 +1,89 @@ > +/* > + * Copyright 2015 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. > + */ > + > +/** @file generatemipmap-cubemap.c > + * > + * Test to make sure that glGenerateMipmap(GL_TEXTURE_CUBE_MAP) works > + * correctly when the cube map texture is generated using glTexImage and not > + * using glTexStorage and glTexSubImage. > + * > + * Attempts to reproduce Mesa Bug 89526. > + */ > + > +#include "piglit-util-gl.h" > + > +PIGLIT_GL_TEST_CONFIG_BEGIN > + > + /* glGenerateMipmap was introduced in OpenGL 3.0. */ > + config.supports_gl_compat_version = 30; > + > + config.window_visual = PIGLIT_GL_VISUAL_RGBA | > + PIGLIT_GL_VISUAL_DOUBLE; > + > +PIGLIT_GL_TEST_CONFIG_END > + > +#define WIDTH 32 > +#define HEIGHT 32 > +#define IMAGE_SIZE (WIDTH * HEIGHT * 4) > + > +static GLubyte *expected; > + > +static void > +init_random_data(void) > +{ > + int i; > + > + expected = malloc(6 * IMAGE_SIZE); > + for (i = 0; i < 6 * IMAGE_SIZE; ++i) { > + expected[i] = (GLubyte) rand(); > + } > +} > + > +void > +piglit_init(int argc, char **argv) > +{ > + srand(0); > + init_random_data(); > +} > + > +enum piglit_result > +piglit_display(void) > +{ > + GLuint tex; > + int i; > + bool pass = true; > + > + glGenTextures(1, &tex); > + glBindTexture(GL_TEXTURE_CUBE_MAP, tex); > + > + for (i = 0; i < 6; ++i) { > + glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, > + 0, GL_RGBA8, WIDTH, HEIGHT, 0, GL_RGBA, > + GL_UNSIGNED_BYTE, expected + i * IMAGE_SIZE); > + } > + > + glGenerateMipmap(GL_TEXTURE_CUBE_MAP); > + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; > + > + return pass ? PIGLIT_PASS : PIGLIT_FAIL; > +} > -- > 2.1.0 > > _______________________________________________ > Piglit mailing list > [email protected] > http://lists.freedesktop.org/mailman/listinfo/piglit
Reviewed-by: Anuj Phogat <[email protected]> _______________________________________________ Piglit mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/piglit
