[Piglit] [PATCH v2] Add tests for GL_AMD_depth_clamp_separate

Marek Olšák maraeo at gmail.com
Fri Sep 7 22:17:37 UTC 2018


Pushed, thanks.

Marek

On Fri, Sep 7, 2018 at 12:43 AM, Sagar Ghuge <sagar.ghuge at intel.com> wrote:
> Ping.
>
> On 08/23/2018 03:12 PM, Sagar Ghuge wrote:
>> v2: 1) Use correct coding style (Ian Romanick)
>>     2) Refactor code (Ian Romanick)
>>     3) Merge DEPTH_CLAMP_NEAR_AMD and DEPTH_CLAMP_FAR_AMD state check in
>>        single file (Ian Romanick)
>>     4) Add missing piglit_require_extension method (Marek Olask)
>>
>> Signed-off-by: Sagar Ghuge <sagar.ghuge at intel.com>
>> Tested-by: Marek Olšák <marek.olsak at amd.com>
>> ---
>>  tests/opengl.py                               |   7 +
>>  tests/spec/CMakeLists.txt                     |   1 +
>>  .../CMakeLists.gl.txt                         |  15 ++
>>  .../amd_depth_clamp_separate/CMakeLists.txt   |   1 +
>>  .../depth-clamp-range.c                       | 161 +++++++++++++++
>>  .../depth-clamp-separate-status.c             | 188 ++++++++++++++++++
>>  6 files changed, 373 insertions(+)
>>  create mode 100644 tests/spec/amd_depth_clamp_separate/CMakeLists.gl.txt
>>  create mode 100644 tests/spec/amd_depth_clamp_separate/CMakeLists.txt
>>  create mode 100644 tests/spec/amd_depth_clamp_separate/depth-clamp-range.c
>>  create mode 100644 tests/spec/amd_depth_clamp_separate/depth-clamp-separate-status.c
>>
>> diff --git a/tests/opengl.py b/tests/opengl.py
>> index 9c5290f49..42e8b3666 100644
>> --- a/tests/opengl.py
>> +++ b/tests/opengl.py
>> @@ -1703,6 +1703,13 @@ with profile.test_list.group_manager(
>>      g(['depth-clamp-range'])
>>      g(['depth-clamp-status'])
>>
>> +# AMD_depth_clamp_separate
>> +with profile.test_list.group_manager(
>> +        PiglitGLTest, grouptools.join('spec', 'AMD_depth_clamp_separate')) as g:
>> +    g(['amd_depth_clamp_separate_status'])
>> +    g(['amd_depth_clamp_separate_range'])
>> +
>> +# Group ARB_draw_elements_base_vertex
>>  # Group ARB_draw_elements_base_vertex
>>  with profile.test_list.group_manager(
>>          PiglitGLTest,
>> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
>> index bb3f02744..4df9d331d 100644
>> --- a/tests/spec/CMakeLists.txt
>> +++ b/tests/spec/CMakeLists.txt
>> @@ -1,4 +1,5 @@
>>  add_subdirectory (amd_framebuffer_multisample_advanced)
>> +add_subdirectory (amd_depth_clamp_separate)
>>  add_subdirectory (amd_performance_monitor)
>>  add_subdirectory (amd_pinned_memory)
>>  add_subdirectory (arb_arrays_of_arrays)
>> diff --git a/tests/spec/amd_depth_clamp_separate/CMakeLists.gl.txt b/tests/spec/amd_depth_clamp_separate/CMakeLists.gl.txt
>> new file mode 100644
>> index 000000000..4f4917262
>> --- /dev/null
>> +++ b/tests/spec/amd_depth_clamp_separate/CMakeLists.gl.txt
>> @@ -0,0 +1,15 @@
>> +include_directories(
>> +     ${GLEXT_INCLUDE_DIR}
>> +     ${OPENGL_INCLUDE_PATH}
>> +)
>> +
>> +link_libraries (
>> +     piglitutil_${piglit_target_api}
>> +     ${OPENGL_gl_LIBRARY}
>> +)
>> +
>> +piglit_add_executable (amd_depth_clamp_separate_status
>> +                    depth-clamp-separate-status.c)
>> +piglit_add_executable (amd_depth_clamp_separate_range depth-clamp-range.c)
>> +
>> +# vim: ft=cmake:
>> diff --git a/tests/spec/amd_depth_clamp_separate/CMakeLists.txt b/tests/spec/amd_depth_clamp_separate/CMakeLists.txt
>> new file mode 100644
>> index 000000000..4a012b958
>> --- /dev/null
>> +++ b/tests/spec/amd_depth_clamp_separate/CMakeLists.txt
>> @@ -0,0 +1 @@
>> +piglit_include_target_api()
>> \ No newline at end of file
>> diff --git a/tests/spec/amd_depth_clamp_separate/depth-clamp-range.c b/tests/spec/amd_depth_clamp_separate/depth-clamp-range.c
>> new file mode 100644
>> index 000000000..b499184d0
>> --- /dev/null
>> +++ b/tests/spec/amd_depth_clamp_separate/depth-clamp-range.c
>> @@ -0,0 +1,161 @@
>> +/*
>> + * Copyright © 2018 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 depth-clamp-range.c
>> + *
>> + * Tests that AMD_depth_clamp_separate enablement didn't break DepthRange
>> + * functionality, and properly uses the min/max selection.
>> + */
>> +
>> +#include "piglit-util-gl.h"
>> +
>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>> +
>> +     config.supports_gl_core_version = 32;
>> +     config.supports_gl_compat_version = 32;
>> +     config.khr_no_error_support = PIGLIT_NO_ERRORS;
>> +     config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE
>> +                            | PIGLIT_GL_VISUAL_DEPTH;
>> +
>> +PIGLIT_GL_TEST_CONFIG_END
>> +
>> +static GLuint program;
>> +static GLint projection_loc;
>> +
>> +static GLuint
>> +make_program(void)
>> +{
>> +     static const char *vs_text =
>> +             "#version 330 \n"
>> +             "in vec4 vertex; \n"
>> +             "uniform mat4 projection; \n"
>> +             "void main() \n"
>> +             "{ \n"
>> +             "   gl_Position = projection * vertex; \n"
>> +             "} \n";
>> +
>> +     static const char *fs_text =
>> +             "#version 330 \n"
>> +             "void main() \n"
>> +             "{ \n"
>> +             "   gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); \n"
>> +             "} \n";
>> +
>> +     GLuint program = piglit_build_simple_program(vs_text, fs_text);
>> +
>> +     return program;
>> +}
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> +     piglit_require_extension("GL_AMD_depth_clamp_separate");
>> +     program = make_program();
>> +}
>> +
>> +enum piglit_result
>> +piglit_display(void)
>> +{
>> +     GLboolean pass = GL_TRUE;
>> +     float white[3] = {1.0, 1.0, 1.0};
>> +     float clear[3] = {0.0, 0.0, 0.0};
>> +
>> +     glClearDepth(0.5);
>> +     glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
>> +     glEnable(GL_DEPTH_TEST);
>> +     glDepthFunc(GL_LEQUAL);
>> +
>> +     glUseProgram(program);
>> +
>> +     projection_loc = glGetUniformLocation(program, "projection");
>> +     piglit_ortho_uniform(projection_loc, piglit_width, piglit_height);
>> +
>> +     /* Keep in mind that the ortho projection flips near and far's signs,
>> +      * so 1.0 to quad()'s z maps to glDepthRange's near, and -1.0 maps to
>> +      * glDepthRange's far.
>> +      */
>> +
>> +     /* Basic glDepthRange testing. */
>> +     glDisable(GL_DEPTH_CLAMP_NEAR_AMD);
>> +     glDisable(GL_DEPTH_CLAMP_FAR_AMD);
>> +     glDepthRange(0, 1);
>> +     piglit_draw_rect_z(0.5, 10, 10, 10, 10); /* .25 - drawn. */
>> +
>> +     glDepthRange(1, 0);
>> +     piglit_draw_rect_z(0.5, 10, 30, 10, 10); /* 0.75 - not drawn. */
>> +
>> +     /* Now, test that near depth clamping works.*/
>> +     glEnable(GL_DEPTH_CLAMP_NEAR_AMD);
>> +     glDepthRange(0.25, 1.0);
>> +     piglit_draw_rect_z(4, 30, 10, 10, 10); /* .25 - drawn. */
>> +
>> +     glDisable(GL_DEPTH_CLAMP_NEAR_AMD);
>> +     glEnable(GL_DEPTH_CLAMP_FAR_AMD);
>> +     glDepthRange(0.75, 1.0);
>> +     piglit_draw_rect_z(4, 30, 30, 10, 10); /* 0.75 - not drawn. */
>> +
>> +     /* Test that far clamping works.*/
>> +     glDepthRange(0.0, 0.25);
>> +     piglit_draw_rect_z(-4, 50, 10, 10, 10); /* .25 - drawn. */
>> +
>> +     glDepthRange(0.0, 0.75);
>> +     piglit_draw_rect_z(-4, 50, 30, 10, 10); /* 0.75 - not drawn. */
>> +
>> +     /* Now, flip near and far around and make sure that it's doing the
>> +      * min/max of near and far in the clamping.
>> +      */
>> +
>> +     /* Test that near (max) clamping works. */
>> +     glEnable(GL_DEPTH_CLAMP_NEAR_AMD);
>> +     glDepthRange(0.25, 0.0);
>> +     piglit_draw_rect_z(4, 70, 10, 10, 10); /* .25 - drawn. */
>> +
>> +     glDisable(GL_DEPTH_CLAMP_NEAR_AMD);
>> +     glEnable(GL_DEPTH_CLAMP_FAR_AMD);
>> +     glDepthRange(0.75, 0.0);
>> +     piglit_draw_rect_z(4, 70, 30, 10, 10); /* 0.75 - not drawn. */
>> +
>> +     /* Now, test far (min) clamping works. */
>> +     glDepthRange(1.0, 0.0);
>> +     piglit_draw_rect_z(-4, 90, 10, 10, 10); /* 0.0 - drawn. */
>> +
>> +     glDisable(GL_DEPTH_CLAMP_FAR_AMD);
>> +     glDepthRange(1.0, 0.75);
>> +     piglit_draw_rect_z(-4, 90, 30, 10, 10); /* 0.75 - drawn. */
>> +
>> +     pass = piglit_probe_pixel_rgb(15, 15, white) && pass;
>> +     pass = piglit_probe_pixel_rgb(15, 35, clear) && pass;
>> +     pass = piglit_probe_pixel_rgb(35, 15, white) && pass;
>> +     pass = piglit_probe_pixel_rgb(35, 35, clear) && pass;
>> +     pass = piglit_probe_pixel_rgb(55, 15, white) && pass;
>> +     pass = piglit_probe_pixel_rgb(55, 35, clear) && pass;
>> +     pass = piglit_probe_pixel_rgb(75, 15, white) && pass;
>> +     pass = piglit_probe_pixel_rgb(75, 35, clear) && pass;
>> +     pass = piglit_probe_pixel_rgb(95, 15, white) && pass;
>> +     pass = piglit_probe_pixel_rgb(95, 35, clear) && pass;
>> +
>> +     piglit_present_results();
>> +
>> +     return pass ? PIGLIT_PASS : PIGLIT_FAIL;
>> +}
>> diff --git a/tests/spec/amd_depth_clamp_separate/depth-clamp-separate-status.c b/tests/spec/amd_depth_clamp_separate/depth-clamp-separate-status.c
>> new file mode 100644
>> index 000000000..582405d56
>> --- /dev/null
>> +++ b/tests/spec/amd_depth_clamp_separate/depth-clamp-separate-status.c
>> @@ -0,0 +1,188 @@
>> +/**
>> + * Copyright © 2018 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.
>> + */
>> +
>> +/**
>> + * Test that GL_DEPTH_CLAMP_FAR_AMD and GL_DEPTH_CLAMP_NEAR_AMD is a
>> + * valid state
>> + *
>> + * Table 6.9 (Transformation state) of OpenGL 4.1 Core added
>> + * DEPTH_CLAMP_FAR_AMD and DEPTH_CLAMP_NEAR_AMD
>> + *
>> + */
>> +
>> +#include "piglit-util-gl.h"
>> +
>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>> +
>> +     config.supports_gl_compat_version = 10;
>> +
>> +PIGLIT_GL_TEST_CONFIG_END
>> +
>> +static bool
>> +check_all_enum_queries(GLenum e, const char *name, GLboolean expected)
>> +{
>> +     GLint i;
>> +     GLfloat f;
>> +     GLboolean b;
>> +     GLdouble d;
>> +
>> +     if (glIsEnabled(e) != expected) {
>> +             fprintf(stderr, "%s was not enabled properly\n", name);
>> +             return false;
>> +     }
>> +
>> +     glGetIntegerv(e, &i);
>> +     if (i != (GLint) expected) {
>> +             fprintf(stderr, "%s: i expected to be 0, but returned %d\n",
>> +                     name, i);
>> +             return false;
>> +     }
>> +
>> +     glGetFloatv(e, &f);
>> +     if (f != (GLfloat) expected) {
>> +             fprintf(stderr, "%s: f expected to be 0.0, but returned %f\n",
>> +                     name, f);
>> +             return false;
>> +     }
>> +
>> +     glGetBooleanv(e, &b);
>> +     if (b != expected) {
>> +             fprintf(stderr, "%s: b expected to be 0, but returned %d\n",
>> +                     name, (int)b);
>> +             return false;
>> +     }
>> +
>> +     glGetDoublev(e, &d);
>> +     if (d != (GLdouble) expected) {
>> +             fprintf(stderr, "%s: d expected to be 0.0, but returned %f\n",
>> +                     name, d);
>> +             return false;
>> +     }
>> +
>> +     return true;
>> +}
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> +     bool pass = true;
>> +
>> +     piglit_require_extension("GL_AMD_depth_clamp_separate");
>> +     piglit_require_extension("GL_ARB_depth_clamp");
>> +
>> +     /* Check the initial state */
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
>> +                                   GL_FALSE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_FAR_AMD",
>> +                                   GL_FALSE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_NEAR_AMD",
>> +                                   GL_FALSE) && pass;
>> +
>> +     glEnable(GL_DEPTH_CLAMP_NEAR_AMD);
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
>> +                                   GL_TRUE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_FAR_AMD",
>> +                                   GL_FALSE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_NEAR_AMD",
>> +                                   GL_TRUE) && pass;
>> +
>> +     glEnable(GL_DEPTH_CLAMP_FAR_AMD);
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
>> +                                   GL_TRUE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_FAR_AMD",
>> +                                   GL_TRUE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_NEAR_AMD",
>> +                                   GL_TRUE) && pass;
>> +
>> +     glDisable(GL_DEPTH_CLAMP_NEAR_AMD);
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
>> +                                   GL_TRUE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_FAR_AMD",
>> +                                   GL_TRUE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_NEAR_AMD",
>> +                                   GL_FALSE) && pass;
>> +
>> +     glDisable(GL_DEPTH_CLAMP_FAR_AMD);
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
>> +                                   GL_FALSE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_FAR_AMD",
>> +                                   GL_FALSE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_NEAR_AMD",
>> +                                   GL_FALSE) && pass;
>> +
>> +     /* The GL_AMD_depth_clamp_separate spec says:
>> +      *
>> +      *    In addition to DEPTH_CLAMP_NEAR_AMD and DEPTH_CLAMP_FAR_AMD,
>> +      *    the token DEPTH_CLAMP may be used to simultaneously enable or
>> +      *    disable depth clamping at both the near and far planes.
>> +      */
>> +     glEnable(GL_DEPTH_CLAMP);
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
>> +                                   GL_TRUE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_FAR_AMD",
>> +                                   GL_TRUE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_NEAR_AMD",
>> +                                   GL_TRUE) && pass;
>> +
>> +     glDisable(GL_DEPTH_CLAMP);
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
>> +                                   GL_FALSE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_FAR_AMD",
>> +                                   GL_FALSE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_NEAR_AMD",
>> +                                   GL_FALSE) && pass;
>> +
>> +     glEnable(GL_DEPTH_CLAMP_FAR_AMD);
>> +     glEnable(GL_DEPTH_CLAMP_NEAR_AMD);
>> +     glDisable(GL_DEPTH_CLAMP);
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP, "GL_DEPTH_CLAMP",
>> +                                   GL_FALSE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_FAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_FAR_AMD",
>> +                                   GL_FALSE) && pass;
>> +     pass = check_all_enum_queries(GL_DEPTH_CLAMP_NEAR_AMD,
>> +                                   "GL_DEPTH_CLAMP_NEAR_AMD",
>> +                                   GL_FALSE) && pass;
>> +
>> +     piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
>> +}
>> +
>> +enum piglit_result
>> +piglit_display(void)
>> +{
>> +     return PIGLIT_FAIL;
>> +}
>>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/piglit


More information about the Piglit mailing list