On Wed, Feb 20, 2019 at 10:22:18PM +0200, Eleni Maria Stea wrote: > A test to check the 2D scissors rect clamping and to reproduce the > following bug on i965: > > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=108999 > --- > tests/general/CMakeLists.gl.txt | 1 + > tests/general/viewport-scissors-clamp.c | 143 ++++++++++++++++++++++++
This name of this test is misleading as it doesn't call glScissor(). > tests/opengl.py | 1 + > 3 files changed, 145 insertions(+) > create mode 100644 tests/general/viewport-scissors-clamp.c > > diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt > index 83189fc42..e60e47cbe 100644 > --- a/tests/general/CMakeLists.gl.txt > +++ b/tests/general/CMakeLists.gl.txt > @@ -132,5 +132,6 @@ piglit_add_executable (clear-accum clear-accum.c) > piglit_add_executable (vs-point_size-zero vs-point_size-zero.c) > piglit_add_executable (triangle-guardband-viewport > triangle-guardband-viewport.c) > piglit_add_executable (teximage-scale-bias teximage-scale-bias.c) > +piglit_add_executable (viewport-scissors-clamp viewport-scissors-clamp.c) > > # vim: ft=cmake: > diff --git a/tests/general/viewport-scissors-clamp.c > b/tests/general/viewport-scissors-clamp.c > new file mode 100644 > index 000000000..590e294a3 > --- /dev/null > +++ b/tests/general/viewport-scissors-clamp.c > @@ -0,0 +1,143 @@ > +/* > + * Copyright © 2019 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. > + * > + * Author: > + * Eleni Maria Stea <es...@igalia.com> > + */ > + > +/* The purpose of this test is to validate the 2d scissors bbox clamping This is more validating viewport clamping isn't it? > + * when the Y is flipped (0 on top). It can be used to reproduce this bug: > + * https://bugs.freedesktop.org/show_bug.cgi?id=108999 > + * and test the fix: https://patchwork.freedesktop.org/series/53830/ > + */ > + > +#include "piglit-util-gl.h" > + > +int win_width = 800; > +int win_height = 600; > + > +PIGLIT_GL_TEST_CONFIG_BEGIN > + > +config.supports_gl_compat_version = 20; > +config.window_width = win_width; > +config.window_height = win_height; Have you considered hardcoding these values? > +config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGB; > +config.khr_no_error_support = PIGLIT_NO_ERRORS; > + > +PIGLIT_GL_TEST_CONFIG_END > + > +static int piglit_error; > +static unsigned int vao, vbo; > +static unsigned int sdrprog; > +static const float varr[] = { -1, -1, 1, -1, 1, 1, -1, -1, 1, 1, -1, 1 }; > + > +static const char *vsdr_src = > + "attribute vec4 vertex;\n" > + "void main()\n" "{\n" "gl_Position = vertex;\n" "}\n"; > + > +static const char *fsdr_src = > + "void main()\n" > + "{\n" "gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);\n" "}\n"; > + > +void > +piglit_init(int argc, char **argv) > +{ > + unsigned int vsdr, fsdr; > + int status; > + > + glGenBuffers(1, &vbo); > + glBindBuffer(GL_ARRAY_BUFFER, vbo); > + glBufferData(GL_ARRAY_BUFFER, sizeof varr, varr, GL_STATIC_DRAW); > + > + glGenVertexArrays(1, &vao); > + glBindVertexArray(vao); > + glEnableVertexAttribArray(0); > + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, 0); > + glBindBuffer(GL_ARRAY_BUFFER, 0); > + glBindVertexArray(0); > + > + /* create shaders */ > + > + vsdr = glCreateShader(GL_VERTEX_SHADER); > + glShaderSource(vsdr, 1, &vsdr_src, 0); > + glCompileShader(vsdr); > + glGetShaderiv(vsdr, GL_COMPILE_STATUS, &status); > + if (!status) { > + fprintf(stderr, "failed to compile vertex shader\n"); > + piglit_error = 1; > + return; > + } > + fsdr = glCreateShader(GL_FRAGMENT_SHADER); > + glShaderSource(fsdr, 1, &fsdr_src, 0); > + glCompileShader(fsdr); > + glGetShaderiv(fsdr, GL_COMPILE_STATUS, &status); > + if (!status) { > + fprintf(stderr, "failed to compile pixel shader\n"); > + piglit_error = 1; > + return; > + } > + > + sdrprog = glCreateProgram(); > + glAttachShader(sdrprog, vsdr); > + glAttachShader(sdrprog, fsdr); > + > + glBindAttribLocation(sdrprog, 0, "vertex"); > + glLinkProgram(sdrprog); Have you considered a piglit helper function like: piglit_build_simple_program() ? > + > + glGetProgramiv(sdrprog, GL_LINK_STATUS, &status); > + if (!status) { > + fprintf(stderr, "failed to link program\n"); > + piglit_error = 1; > + return; > + } > + > + glUseProgram(sdrprog); > + > + if (glGetError() != GL_NO_ERROR) > + piglit_error = 1; > +} > + > +enum piglit_result > +piglit_display(void) > +{ > + if (piglit_error) > + return PIGLIT_FAIL; > + > + glBindVertexArray(vao); > + > + glViewport(2, 602, 262, 296); > + > + glDrawArrays(GL_TRIANGLES, 0, 6); > + > + glViewport(0, 0, 800, 600); > + > + glDrawArrays(GL_TRIANGLES, 0, 6); > + > + glBindVertexArray(0); > + > + if (glGetError() != GL_NO_ERROR) > + return PIGLIT_FAIL; > + > + piglit_swap_buffers(); > + > + return PIGLIT_PASS; > +} > diff --git a/tests/opengl.py b/tests/opengl.py > index 8e84e2cfc..dff843d6d 100644 > --- a/tests/opengl.py > +++ b/tests/opengl.py > @@ -878,6 +878,7 @@ with profile.test_list.group_manager( > g(['incomplete-cubemap', 'format'], 'incomplete-cubemap-format') > g(['gl-2.0-texture-units']) > g(['gl-2.0-uniform-neg-location']) > + g(['viewport-scissors-clamp']) > > with profile.test_list.group_manager( > PiglitGLTest, > -- > 2.20.1 > _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit