Thank you for such a constructive comments/suggestions. I took a reference from existing depth_clamp tests. I will apply your suggestions to both the new tests and existing tests and send next revision.
Thank you so much for reviewing the series. On 08/22/2018 01:37 PM, Ian Romanick wrote: > On 08/21/2018 05:05 PM, Sagar Ghuge wrote: >> Signed-off-by: Sagar Ghuge <sagar.gh...@intel.com> >> --- >> tests/opengl.py | 8 + >> tests/spec/CMakeLists.txt | 1 + >> .../CMakeLists.gl.txt | 15 ++ >> .../amd_depth_clamp_separate/CMakeLists.txt | 1 + >> .../depth-clamp-far-status.c | 147 ++++++++++++++++ >> .../depth-clamp-near-status.c | 148 ++++++++++++++++ >> .../depth-clamp-range.c | 159 ++++++++++++++++++ >> 7 files changed, 479 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-far-status.c >> create mode 100644 >> tests/spec/amd_depth_clamp_separate/depth-clamp-near-status.c >> create mode 100644 tests/spec/amd_depth_clamp_separate/depth-clamp-range.c >> >> diff --git a/tests/opengl.py b/tests/opengl.py >> index 9c5290f49..fc35a61b2 100644 >> --- a/tests/opengl.py >> +++ b/tests/opengl.py >> @@ -1703,6 +1703,14 @@ 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_far_status']) >> + g(['amd_depth_clamp_near_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..40dad8f53 >> --- /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_near_status >> depth-clamp-near-status.c) >> +piglit_add_executable (amd_depth_clamp_far_status depth-clamp-far-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-far-status.c >> b/tests/spec/amd_depth_clamp_separate/depth-clamp-far-status.c >> new file mode 100644 >> index 000000000..9d1accd79 >> --- /dev/null >> +++ b/tests/spec/amd_depth_clamp_separate/depth-clamp-far-status.c >> @@ -0,0 +1,147 @@ >> +/** >> + * 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 is a valid state >> + * >> + * Table 6.9 (Transformation state) of OpenGL 4.1 Core added >> + * DEPTH_CLAMP_FAR_AMD >> + * >> + */ >> + >> +#include "piglit-util-gl.h" >> + >> +PIGLIT_GL_TEST_CONFIG_BEGIN >> + >> + config.supports_gl_core_version = 41; > > The spec was written against OpenGL 4.1, but I don't think it requires > it. I think this test could be config.supports_gl_compat_version = 10. > If you adjust the version to 320 in the test that uses shaders, it could be > config.supports_gl_core_version = 32. > >> + >> +PIGLIT_GL_TEST_CONFIG_END >> + >> +void >> +piglit_init(int argc, char **argv) >> +{ >> + bool pass = true; >> + GLint i; >> + GLfloat f; >> + GLboolean b; >> + GLdouble d; >> + >> + /* Check that GL_DEPTH_CLAMP_FAR_AMD was initialized to TRUE */ >> + if (glIsEnabled(GL_DEPTH_CLAMP_FAR_AMD)) { >> + printf("GL_DEPTH_CLAMP_FAR_AMD was not initialized to FALSE\n"); > > Either the comment is misleading or the printf is wrong. Maybe the > comment should be "Check that GL_DEPTH_CLAMP_FAR_AMD is initially > disabled." > >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + >> + /* Test that GL_DEPTH_CLAMP_FAR_AMD >> + * is enable/disabled correctly >> + */ > > Line wrap to 78 columns. > > /* Test that GL_DEPTH_CLAMP_FAR_AMD is enable/disabled correctly. */ > >> + glEnable(GL_DEPTH_CLAMP_FAR_AMD); >> + if (!glIsEnabled(GL_DEPTH_CLAMP_FAR_AMD)) { >> + printf("GL_DEPTH_CLAMP_FAR_AMD was not enabled properly\n"); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + >> + /* Test that glIsEnabled(GL_DEPTH_CLAMP) is true >> + * if glEnable(GL_DEPTH_CLAMP_FAR_AMD) true >> + */ > > Same line wrap comment. But for this, I would use a quotation from the > spec to justify the test. > > /* The GL_AMD_depth_clamp_separate spec says: > * > * Querying DEPTH_CLAMP will return TRUE if DEPTH_CLAMP_NEAR_AMD > * _or_ DEPTH_CLAMP_FAR_AMD is enabled. > */ > >> + if (!glIsEnabled(GL_DEPTH_CLAMP)) { >> + printf("GL_DEPTH_CLAMP was not enabled properly\n"); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + >> + glDisable(GL_DEPTH_CLAMP_FAR_AMD); >> + if (glIsEnabled(GL_DEPTH_CLAMP_FAR_AMD)) { >> + printf("GL_DEPTH_CLAMP_FAR_AMD was not disabled properly\n"); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + >> + /* Test that GL_DEPTH_CLAMP_FAR_AMD >> + * disabled is returned from glGet calls >> + */ > > Same line wrap comment. > >> + glGetIntegerv(GL_DEPTH_CLAMP_FAR_AMD, &i); >> + if(i != 0) { > ^ > Missing space here. > >> + printf("i expected to be 0, but returned %d\n", i); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; > > Add a blank line here. > >> + glGetFloatv(GL_DEPTH_CLAMP_FAR_AMD, &f); >> + if(f != 0.0f) { > ^ > Missing space here. > >> + printf("f expected to be 0.0, but returned %f\n", f); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; > > Add a blank line here. > >> + glGetBooleanv(GL_DEPTH_CLAMP_FAR_AMD, &b); >> + if(b != GL_FALSE) { > ^ > Missing space here. > >> + printf("b expected to be 0, but returned %d\n", (int)b); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; > > Add a blank line here. > >> + glGetDoublev(GL_DEPTH_CLAMP_FAR_AMD, &d); >> + if(d != 0.0) { > ^ > Missing space here. > > Wow... this is very thorough. :) I think all of this could get > refactored into a function like > > bool > check_boolean_enum_query(GLenum e, GLboolean expected) > { > > if (glIsEnabled(e) != expected) { > ... > } > > GLboolean b; > glGetBooleanv(e, &b); > if (b != expected) { > ... > } > > GLint i; > glGetIntegerv(e, &i); > if (i != (GLint) expected) { > ... > } > > ... > } > > check_boolean_enum_query might not be the best name. Maybe > check_all_queries_related_to_an_enable? I don't know. If you want to > make the error message more specific, you could also add a char * > parameter. > > Then it would be trivial to put the test and the GL_DEPTH_CLAMP_NEAR_AMD > test in the same file. You would just have > > pass = true; > > // Check the initial state. > pass = check_boolean_enum_query(GL_DEPTH_CLAMP, GL_FALSE) && pass; > pass = check_boolean_enum_query(GL_DEPTH_CLAMP_FAR_AMD, GL_FALSE) && > pass > pass = check_boolean_enum_query(GL_DEPTH_CLAMP_NEAR_AMD, GL_FALSE) && > pass; > > glEnable(GL_DEPTH_CLAMP_NEAR_AMD); > pass = check_boolean_enum_query(GL_DEPTH_CLAMP, GL_TRUE) && pass; > pass = check_boolean_enum_query(GL_DEPTH_CLAMP_FAR_AMD, GL_FALSE) && > pass; > pass = check_boolean_enum_query(GL_DEPTH_CLAMP_NEAR_AMD, GL_TRUE) && > pass; > > glEnable(GL_DEPTH_CLAMP_FAR_AMD); > pass = check_boolean_enum_query(GL_DEPTH_CLAMP, GL_TRUE) && pass; > pass = check_boolean_enum_query(GL_DEPTH_CLAMP_FAR_AMD, GL_TRUE) && > pass; > pass = check_boolean_enum_query(GL_DEPTH_CLAMP_NEAR_AMD, GL_TRUE) && > pass; > > glDisable(GL_DEPTH_CLAMP_NEAR_AMD); > pass = check_boolean_enum_query(GL_DEPTH_CLAMP, GL_TRUE) && pass; > pass = check_boolean_enum_query(GL_DEPTH_CLAMP_FAR_AMD, GL_TRUE) && > pass; > pass = check_boolean_enum_query(GL_DEPTH_CLAMP_NEAR_AMD, GL_FALSE) && > pass; > > glDisable(GL_DEPTH_CLAMP_NEAR_AMD); > pass = check_boolean_enum_query(GL_DEPTH_CLAMP, GL_FALSE) && pass; > pass = check_boolean_enum_query(GL_DEPTH_CLAMP_FAR_AMD, GL_FALSE) && > pass; > pass = check_boolean_enum_query(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_boolean_enum_query(GL_DEPTH_CLAMP, GL_TRUE) && pass; > pass = check_boolean_enum_query(GL_DEPTH_CLAMP_FAR_AMD, GL_TRUE) && > pass; > pass = check_boolean_enum_query(GL_DEPTH_CLAMP_NEAR_AMD, GL_TRUE) && > pass; > > glDisable(GL_DEPTH_CLAMP); > pass = check_boolean_enum_query(GL_DEPTH_CLAMP, GL_FALSE) && pass; > pass = check_boolean_enum_query(GL_DEPTH_CLAMP_FAR_AMD, GL_FALSE) && > pass; > pass = check_boolean_enum_query(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_boolean_enum_query(GL_DEPTH_CLAMP, GL_FALSE) && pass; > pass = check_boolean_enum_query(GL_DEPTH_CLAMP_FAR_AMD, GL_FALSE) && > pass; > pass = check_boolean_enum_query(GL_DEPTH_CLAMP_NEAR_AMD, GL_FALSE) && > pass; > > I think this last block of tests is missing from your tests. Adding > them without the refactor that I suggested would be very painful. > >> + printf("d expected to be 0.0, but returned %f\n", d); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + >> + /* Test that GL_DEPTH_CLAMP_FAR_AMD enabled >> + * is returned from glGet calls >> + */ >> + glEnable(GL_DEPTH_CLAMP_FAR_AMD); >> + >> + glGetIntegerv(GL_DEPTH_CLAMP_FAR_AMD, &i); >> + if(i != 1) { >> + printf("i expected to be 1, but returned %d\n", i); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + glGetFloatv(GL_DEPTH_CLAMP_FAR_AMD, &f); >> + if(f != 1.0f) { >> + printf("f expected to be 1.0, but returned %f\n", f); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + glGetBooleanv(GL_DEPTH_CLAMP_FAR_AMD, &b); >> + if(b != GL_TRUE) { >> + printf("b expected to be 1, but returned %d\n", (int)b); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + glGetDoublev(GL_DEPTH_CLAMP_FAR_AMD, &d); >> + if(d != 1.0) { >> + printf("d expected to be 1.0, but returned %f\n", d); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + >> + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); >> +} >> + >> +enum piglit_result >> +piglit_display(void) >> +{ >> + return PIGLIT_FAIL; >> +} >> diff --git a/tests/spec/amd_depth_clamp_separate/depth-clamp-near-status.c >> b/tests/spec/amd_depth_clamp_separate/depth-clamp-near-status.c >> new file mode 100644 >> index 000000000..6da059d9e >> --- /dev/null >> +++ b/tests/spec/amd_depth_clamp_separate/depth-clamp-near-status.c >> @@ -0,0 +1,148 @@ >> +/** >> + * 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_NEAR_AMD is a valid state >> + * >> + * Table 6.9 (Transformation state) of OpenGL 4.1 Core added >> + * DEPTH_CLAMP_NEAR_AMD >> + * >> + */ >> + >> +#include "piglit-util-gl.h" >> + >> +PIGLIT_GL_TEST_CONFIG_BEGIN >> + >> + config.supports_gl_core_version = 41; >> + >> +PIGLIT_GL_TEST_CONFIG_END >> + >> +void >> +piglit_init(int argc, char **argv) >> +{ >> + bool pass = true; >> + GLint i; >> + GLfloat f; >> + GLboolean b; >> + GLdouble d; >> + >> + /* Check that GL_DEPTH_CLAMP_NEAR_AMD was initialized to TRUE */ >> + if (glIsEnabled(GL_DEPTH_CLAMP_NEAR_AMD)) { >> + printf("GL_DEPTH_CLAMP_NEAR_AMD was not initialized to >> FALSE\n"); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + >> + /* Test that GL_DEPTH_CLAMP_NEAR_AMD >> + * is enable/disabled correctly >> + */ >> + glEnable(GL_DEPTH_CLAMP_NEAR_AMD); >> + if (!glIsEnabled(GL_DEPTH_CLAMP_NEAR_AMD)) { >> + printf("GL_DEPTH_CLAMP_NEAR_AMD was not enabled properly\n"); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + >> + /* Test that glIsEnabled(GL_DEPTH_CLAMP) is true >> + * if glEnable(GL_DEPTH_CLAMP_NEAR_AMD) true >> + */ >> + if (!glIsEnabled(GL_DEPTH_CLAMP)) { >> + printf("GL_DEPTH_CLAMP was not enabled properly\n"); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + >> + glDisable(GL_DEPTH_CLAMP_NEAR_AMD); >> + if (glIsEnabled(GL_DEPTH_CLAMP_NEAR_AMD)) { >> + printf("GL_DEPTH_CLAMP_NEAR_AMD was not disabled properly\n"); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + >> + /* Test that GL_DEPTH_CLAMP_NEAR_AMD >> + * disabled is returned from glGet calls >> + */ >> + glGetIntegerv(GL_DEPTH_CLAMP_NEAR_AMD, &i); >> + if(i != 0) { >> + printf("i expected to be 0, but returned %d\n", i); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + glGetFloatv(GL_DEPTH_CLAMP_NEAR_AMD, &f); >> + if(f != 0.0f) { >> + printf("f expected to be 0.0, but returned %f\n", f); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + glGetBooleanv(GL_DEPTH_CLAMP_NEAR_AMD, &b); >> + if(b != GL_FALSE) { >> + printf("b expected to be 0, but returned %d\n", (int)b); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + glGetDoublev(GL_DEPTH_CLAMP_NEAR_AMD, &d); >> + if(d != 0.0) { >> + printf("d expected to be 0.0, but returned %f\n", d); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + >> + >> + /* Test that GL_DEPTH_CLAMP_NEAR_AMD enabled >> + * is returned from glGet calls >> + */ >> + glEnable(GL_DEPTH_CLAMP_NEAR_AMD); >> + >> + glGetIntegerv(GL_DEPTH_CLAMP_NEAR_AMD, &i); >> + if(i != 1) { >> + printf("i expected to be 1, but returned %d\n", i); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + glGetFloatv(GL_DEPTH_CLAMP_NEAR_AMD, &f); >> + if(f != 1.0f) { >> + printf("f expected to be 1.0, but returned %f\n", f); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + glGetBooleanv(GL_DEPTH_CLAMP_NEAR_AMD, &b); >> + if(b != GL_TRUE) { >> + printf("b expected to be 1, but returned %d\n", (int)b); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + glGetDoublev(GL_DEPTH_CLAMP_NEAR_AMD, &d); >> + if(d != 1.0) { >> + printf("d expected to be 1.0, but returned %f\n", d); >> + pass = false; >> + } >> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass; >> + >> + piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL); >> +} >> + >> +enum piglit_result >> +piglit_display(void) >> +{ >> + return PIGLIT_FAIL; >> +} >> 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..37fc4a831 >> --- /dev/null >> +++ b/tests/spec/amd_depth_clamp_separate/depth-clamp-range.c >> @@ -0,0 +1,159 @@ >> +/* >> + * 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 = 41; >> + 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; >> +} >> > _______________________________________________ Piglit mailing list Piglit@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/piglit