[Piglit] [PATCH] gl-3.1: Add test for attributeless rendering with gl_VertexID

Jordan Justen jljusten at gmail.com
Tue Apr 22 10:33:46 PDT 2014


Could this be a shader_test instead?

But, shader_runner is sort of in limbo for attributeless rendering.
(See also b28cdc88 and revert of that same commit in c20596b8.)

On Tue, Apr 22, 2014 at 2:47 PM, Chris Forbes <chrisf at ijw.co.nz> wrote:
> This tests that rendering with no vertex attributes bound works, in the
> core profile. The vertex positions are determined using gl_VertexID.
>
> This currently provokes some bad behavior in the i965 backend --
> the whole array of constant data gets spilled to scratch to support the
> nonconstant index.
>
> Signed-off-by: Chris Forbes <chrisf at ijw.co.nz>
> ---
>  tests/all.py                               |  1 +
>  tests/spec/gl-3.1/CMakeLists.gl.txt        |  1 +
>  tests/spec/gl-3.1/attributeless-vertexid.c | 85 ++++++++++++++++++++++++++++++
>  3 files changed, 87 insertions(+)
>  create mode 100644 tests/spec/gl-3.1/attributeless-vertexid.c
>
> diff --git a/tests/all.py b/tests/all.py
> index 49c801a..e6134a9 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -1075,6 +1075,7 @@ for subtest in ['generated', 'written', 'flush']:
>  gl31['required-renderbuffer-attachment-formats'] = concurrent_test('gl-3.0-required-renderbuffer-attachment-formats 31')
>  gl31['required-sized-texture-formats'] = concurrent_test('gl-3.0-required-sized-texture-formats 31')
>  gl31['required-texture-attachment-formats'] = concurrent_test('gl-3.0-required-texture-attachment-formats 31')
> +gl31['attributeless-vertexid'] = concurrent_test('gl-3.1-attributeless-vertexid')
>
>  gl32 = {}
>  spec['!OpenGL 3.2'] = gl32
> diff --git a/tests/spec/gl-3.1/CMakeLists.gl.txt b/tests/spec/gl-3.1/CMakeLists.gl.txt
> index 7d835e8..cb60eb9 100644
> --- a/tests/spec/gl-3.1/CMakeLists.gl.txt
> +++ b/tests/spec/gl-3.1/CMakeLists.gl.txt
> @@ -13,5 +13,6 @@ piglit_add_executable (gl-3.1-draw-buffers-errors draw-buffers-errors.c)
>  piglit_add_executable (gl-3.1-genned-names genned-names.c)
>  piglit_add_executable (gl-3.1-minmax minmax.c)
>  piglit_add_executable (gl-3.1-primitive-restart-xfb primitive-restart-xfb.c)
> +piglit_add_executable (gl-3.1-attributeless-vertexid attributeless-vertexid.c)
>
>  # vim: ft=cmake:
> diff --git a/tests/spec/gl-3.1/attributeless-vertexid.c b/tests/spec/gl-3.1/attributeless-vertexid.c
> new file mode 100644
> index 0000000..012c460
> --- /dev/null
> +++ b/tests/spec/gl-3.1/attributeless-vertexid.c
> @@ -0,0 +1,85 @@
> +/* Copyright © 2014 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 attributeless-vertexid.c
> + *
> + * Test that rendering with no vertex attributes (but only using gl_VertexID)
> + * works in the core profile.
> + */
> +
> +#include "piglit-util-gl-common.h"
> +#include "minmax-test.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +       config.supports_gl_core_version = 31;
> +       config.window_visual = PIGLIT_GL_VISUAL_DOUBLE | PIGLIT_GL_VISUAL_RGBA;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +const float red[] = { 1, 0, 0, 1 };
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +       bool pass;
> +
> +       glViewport(0, 0, piglit_width, piglit_height);
> +       glClearColor(0.2, 0.2, 0.2, 0.2);
> +       glClear(GL_COLOR_BUFFER_BIT);
> +
> +       glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
> +
> +       pass = piglit_probe_rect_rgba(0, 0, piglit_width, piglit_height, red);
> +
> +       piglit_present_results();
> +
> +       return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +       GLuint prog = piglit_build_simple_program(
> +               "#version 140\n"
> +               "const vec2 verts[4] = vec2[](\n"
> +               "       vec2(-1, 1),\n"
> +               "       vec2(-1,-1),\n"
> +               "       vec2( 1,-1),\n"
> +               "       vec2( 1, 1)\n"
> +               ");\n"
> +               "void main() {\n"
> +               "       gl_Position = vec4(verts[gl_VertexID], 0, 1);\n"
> +               "}\n",
> +
> +               "#version 140\n"
> +               "void main() {\n"
> +               "       gl_FragColor = vec4(1,0,0,1);\n"
> +               "}\n");
> +
> +       GLuint vao;
> +
> +       glUseProgram(prog);
> +
> +       glGenVertexArrays(1, &vao);
> +       glBindVertexArray(vao);
> +}
> --
> 1.9.1
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list