[Piglit] [PATCH 1/5] arb_post_depth_coverage-basic: Add a basic initial test.

Manolova, Plamena plamena.manolova at intel.com
Thu Nov 10 12:03:45 UTC 2016


________________________________________
From: ibmirkin at gmail.com [ibmirkin at gmail.com] on behalf of Ilia Mirkin [imirkin at alum.mit.edu]
Sent: 10 November 2016 01:49
To: Manolova, Plamena
Cc: piglit at lists.freedesktop.org
Subject: Re: [Piglit] [PATCH 1/5] arb_post_depth_coverage-basic: Add a basic initial test.

On Wed, Nov 9, 2016 at 6:39 PM, Plamena Manolova
<plamena.manolova at intel.com> wrote:
> A basic test to check whether the values written to gl_SampleMaskIn
> are still correct after enabling the ARB_post_depth_coverage
> extension.
>
> Signed-off-by: Plamena Manolova <plamena.manolova at intel.com>
> ---
>  registry/gl.xml                                    |   2 +
>  tests/all.py                                       |   5 +
>  tests/spec/CMakeLists.txt                          |   1 +
>  .../spec/arb_post_depth_coverage/CMakeLists.gl.txt |  11 ++
>  tests/spec/arb_post_depth_coverage/CMakeLists.txt  |   1 +
>  tests/spec/arb_post_depth_coverage/basic.c         | 165 +++++++++++++++++++++
>  6 files changed, 185 insertions(+)
>  create mode 100644 tests/spec/arb_post_depth_coverage/CMakeLists.gl.txt
>  create mode 100644 tests/spec/arb_post_depth_coverage/CMakeLists.txt
>  create mode 100644 tests/spec/arb_post_depth_coverage/basic.c
>
> diff --git a/registry/gl.xml b/registry/gl.xml
> index 3fc8863..59894e8 100644
> --- a/registry/gl.xml
> +++ b/registry/gl.xml

This file comes from Khronos and should be synchronized accordingly.
It appears that there's already a line

        <extension name="GL_ARB_post_depth_coverage" supported="gl"/>

in there. Not sure why you needed your change in the first place, this
only matters for dispatch, of which there is none for this ext.

> @@ -38345,6 +38345,8 @@ typedef unsigned int GLhandleARB;
>                  <enum name="GL_ANY_SAMPLES_PASSED"/>
>              </require>
>          </extension>
> +        <extension name="GL_ARB_post_depth_coverage" supported="gl|glcore">
> +        </extension>
>          <extension name="GL_ARB_parallel_shader_compile" supported="gl">
>              <require>
>                  <enum name="GL_MAX_SHADER_COMPILER_THREADS_ARB"/>
> diff --git a/tests/all.py b/tests/all.py
> index e56cae8..d47187e 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -4766,6 +4766,11 @@ with profile.group_manager(
>      g(['arb_shader_image_load_store-unused'], 'unused')
>
>  with profile.group_manager(
> +        PiglitGLTest,
> +        grouptools.join('spec', 'arb_post_depth_coverage')) as g:
> +    g(['arb_post_depth_coverage-basic'])
> +
> +with profile.group_manager(
>      PiglitGLTest,
>      grouptools.join('spec', 'arb_shader_image_size')) as g:
>      g(['arb_shader_image_size-builtin'], 'builtin')
> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
> index a057c02..4377196 100644
> --- a/tests/spec/CMakeLists.txt
> +++ b/tests/spec/CMakeLists.txt
> @@ -152,3 +152,4 @@ add_subdirectory (arb_query_buffer_object)
>  add_subdirectory (ext_window_rectangles)
>  add_subdirectory (arb_shader_texture_image_samples)
>  add_subdirectory (arb_texture_barrier)
> +add_subdirectory (arb_post_depth_coverage)
> diff --git a/tests/spec/arb_post_depth_coverage/CMakeLists.gl.txt b/tests/spec/arb_post_depth_coverage/CMakeLists.gl.txt
> new file mode 100644
> index 0000000..1a71774
> --- /dev/null
> +++ b/tests/spec/arb_post_depth_coverage/CMakeLists.gl.txt
> @@ -0,0 +1,11 @@
> +include_directories(
> +       ${GLEXT_INCLUDE_DIR}
> +       ${OPENGL_INCLUDE_PATH}
> +)
> +
> +link_libraries (
> +       piglitutil_${piglit_target_api}
> +       ${OPENGL_gl_LIBRARY}
> +)
> +
> +piglit_add_executable (arb_post_depth_coverage-basic basic.c)
> diff --git a/tests/spec/arb_post_depth_coverage/CMakeLists.txt b/tests/spec/arb_post_depth_coverage/CMakeLists.txt
> new file mode 100644
> index 0000000..144a306
> --- /dev/null
> +++ b/tests/spec/arb_post_depth_coverage/CMakeLists.txt
> @@ -0,0 +1 @@
> +piglit_include_target_api()
> diff --git a/tests/spec/arb_post_depth_coverage/basic.c b/tests/spec/arb_post_depth_coverage/basic.c
> new file mode 100644
> index 0000000..e1bd71f
> --- /dev/null
> +++ b/tests/spec/arb_post_depth_coverage/basic.c
> @@ -0,0 +1,165 @@
> +/*
> + * Copyright (c) 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.
> + */
> +
> +#include "piglit-util-gl.h"
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +       config.supports_gl_compat_version = 45;
> +       config.supports_gl_core_version = 45;
> +       config.window_width = 160;
> +       config.window_height = 160;
> +       config.window_visual = PIGLIT_GL_VISUAL_DEPTH | PIGLIT_GL_VISUAL_RGBA;
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +static GLuint prog, vao, ssbo;
> +static GLint *sample_mask;
> +
> +static GLuint
> +make_shader_program(void)
> +{
> +       static const char *vs_text =
> +               "#version 430\n"
> +               "in vec4 pos_in;\n"
> +               "void main()\n"
> +               "{\n"
> +               "       gl_Position = pos_in;\n"

I think if you use something called "piglit_vertex", you can just use
piglit_draw_rect or whatever and avoid having to do all the vertex
stuff by hand.

> +               "}\n";
> +
> +       static const char *fs_text =
> +               "#version 430\n"
> +               "out vec4 color;\n"
> +               "layout(early_fragment_tests) in;\n"
> +               "layout(post_depth_coverage) in;\n"
> +               "layout(std430, binding = 0) buffer MaskOutput {"

buffer restrict

> +               "       int data[25600];"
> +               "} mask_output;"
> +               "void main()\n"
> +               "{\n"
> +               "       int index = int(gl_FragCoord.y) * 160 + int(gl_FragCoord.x);\n"
> +               "       mask_output.data[index] = gl_SampleMaskIn[0] & 0x1;\n"
> +               "       color = vec4(1.0, 0.0, 0.0, 1.0);\n"
> +               "}\n";
> +
> +       GLuint prog;
> +
> +       prog = piglit_build_simple_program(vs_text, fs_text);
> +       glUseProgram(prog);
> +
> +       glBindAttribLocation(prog, 0, "pos_in");
> +
> +       glLinkProgram(prog);
> +
> +       if (!piglit_check_gl_error(GL_NO_ERROR)) {
> +               piglit_report_result(PIGLIT_FAIL);
> +       }
> +
> +       return prog;
> +}
> +
> +static void
> +make_ssbo(void)
> +{
> +       glGenBuffers(1, &ssbo);
> +       glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo);
> +}
> +
> +static GLuint
> +make_vao(void)
> +{
> +       static const float pos_tc[4][2] = {
> +               { -1.0, -1.0 },
> +               {  1.0, -1.0 },
> +               {  1.0,  1.0 },
> +               { -1.0,  1.0 }
> +       };
> +       const int stride = sizeof(pos_tc[0]);
> +       GLuint vbo, vao;
> +
> +       glGenVertexArrays(1, &vao);
> +       glBindVertexArray(vao);
> +
> +       glGenBuffers(1, &vbo);
> +       glBindBuffer(GL_ARRAY_BUFFER, vbo);
> +       glBufferData(GL_ARRAY_BUFFER, sizeof(pos_tc), pos_tc, GL_STATIC_DRAW);
> +       piglit_check_gl_error(GL_NO_ERROR);
> +
> +       glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, stride, (void *) 0);
> +
> +       glEnableVertexAttribArray(0);
> +
> +       if (!piglit_check_gl_error(GL_NO_ERROR)) {
> +               piglit_report_result(PIGLIT_FAIL);
> +       }
> +
> +       return vbo;
> +}
> +
> +
> +void
> +piglit_init(int argc, char **argv)
> +{
> +       piglit_require_gl_version(45);
> +       piglit_require_extension("GL_ARB_post_depth_coverage");
> +       prog = make_shader_program();
> +       vao = make_vao();
> +       make_ssbo();
> +}
> +
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +       float red[4] = {1.0, 0.0, 0.0, 1.0};
> +       bool pass = true;
> +       int i;
> +
> +       glViewport(0, 0, piglit_width, piglit_height);
> +       sample_mask = (GLint*) malloc (sizeof(GLint) * piglit_width * piglit_height);
> +       glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(GLint) * piglit_width *
> +               piglit_height, &sample_mask[0], GL_DYNAMIC_DRAW);

This will upload random stuff into the ssbo on start. I think you can
just pass NULL in.

> +       glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, ssbo);
> +
> +       glClearColor(0.0, 0.0, 0.0, 1.0);
> +       glClear(GL_COLOR_BUFFER_BIT);
> +       glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
> +
> +       glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);
> +       glGetBufferSubData(GL_SHADER_STORAGE_BUFFER, 0, sizeof(GLint) *
> +               piglit_width * piglit_height, &sample_mask[0]);
> +
> +       for (i = 0; i < piglit_width * piglit_height; i++)
> +       {
> +               if (sample_mask[i] != 1) {

So ... you don't have a depth test set up. And you're not using
multi-sampling. How would this detect a no-op implementation, for
example, that just parsed the layout param and did nothing with it?

Hi Ilia, thank you for reviewing! This is the first patch from a series
of tests that I got ready for the arb_post_depth_coverage extension.
The other 3 test the depth, stencil and multisampling capabilities.
I made this test just to check whether the values in gl_SampleMaskIn
are still correct after enabling the extension. I can combine this
test with one of the others if you think there's no point to have it
standalone.

> +                       pass = false;
> +                       break;
> +               }
> +       }
> +
> +       pass = piglit_probe_rect_rgba(0, 0, 160, 160, red) && pass;
> +       piglit_present_results();
> +
> +       pass = piglit_check_gl_error(GL_NO_ERROR) && pass;
> +
> +       free(sample_mask);
> +       return pass ? PIGLIT_PASS : PIGLIT_FAIL;
> +}
> --
> 2.7.4
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list