<p dir="ltr"></p>
<p dir="ltr">On Nov 17, 2016 10:56 AM, "Plamena Manolova" <<a href="mailto:plamena.manolova@intel.com">plamena.manolova@intel.com</a>> wrote:<br>
><br>
> A basic test to check whether the values written to gl_SampleMaskIn<br>
> are still correct after enabling the ARB_post_depth_coverage<br>
> extension.<br>
><br>
> Signed-off-by: Plamena Manolova <<a href="mailto:plamena.manolova@intel.com">plamena.manolova@intel.com</a>><br>
> ---<br>
> tests/all.py | 5 +<br>
> tests/spec/CMakeLists.txt | 1 +<br>
> .../spec/arb_post_depth_coverage/CMakeLists.gl.txt | 11 +<br>
> tests/spec/arb_post_depth_coverage/CMakeLists.txt | 1 +<br>
> tests/spec/arb_post_depth_coverage/basic.c | 237 +++++++++++++++++++++<br>
> 5 files changed, 255 insertions(+)<br>
> create mode 100644 tests/spec/arb_post_depth_coverage/CMakeLists.gl.txt<br>
> create mode 100644 tests/spec/arb_post_depth_coverage/CMakeLists.txt<br>
> create mode 100644 tests/spec/arb_post_depth_coverage/basic.c<br>
><br>
> diff --git a/tests/all.py b/tests/all.py<br>
> index 16c46e8..9f47da5 100644<br>
> --- a/tests/all.py<br>
> +++ b/tests/all.py<br>
> @@ -4755,6 +4755,11 @@ with profile.test_list.group_manager(<br>
> g(['arb_shader_image_load_store-unused'], 'unused')<br>
><br>
> with profile.test_list.group_manager(<br>
> + PiglitGLTest,<br>
> + grouptools.join('spec', 'arb_post_depth_coverage')) as g:<br>
> + g(['arb_post_depth_coverage-basic'])<br>
> +<br>
> +with profile.test_list.group_manager(<br>
> PiglitGLTest,<br>
> grouptools.join('spec', 'arb_shader_image_size')) as g:<br>
> g(['arb_shader_image_size-builtin'], 'builtin')<br>
> diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt<br>
> index a057c02..4377196 100644<br>
> --- a/tests/spec/CMakeLists.txt<br>
> +++ b/tests/spec/CMakeLists.txt<br>
> @@ -152,3 +152,4 @@ add_subdirectory (arb_query_buffer_object)<br>
> add_subdirectory (ext_window_rectangles)<br>
> add_subdirectory (arb_shader_texture_image_samples)<br>
> add_subdirectory (arb_texture_barrier)<br>
> +add_subdirectory (arb_post_depth_coverage)<br>
> diff --git a/tests/spec/arb_post_depth_coverage/CMakeLists.gl.txt b/tests/spec/arb_post_depth_coverage/CMakeLists.gl.txt<br>
> new file mode 100644<br>
> index 0000000..1a71774<br>
> --- /dev/null<br>
> +++ b/tests/spec/arb_post_depth_coverage/CMakeLists.gl.txt<br>
> @@ -0,0 +1,11 @@<br>
> +include_directories(<br>
> + ${GLEXT_INCLUDE_DIR}<br>
> + ${OPENGL_INCLUDE_PATH}<br>
> +)<br>
> +<br>
> +link_libraries (<br>
> + piglitutil_${piglit_target_api}<br>
> + ${OPENGL_gl_LIBRARY}<br>
> +)<br>
> +<br>
> +piglit_add_executable (arb_post_depth_coverage-basic basic.c)<br>
> diff --git a/tests/spec/arb_post_depth_coverage/CMakeLists.txt b/tests/spec/arb_post_depth_coverage/CMakeLists.txt<br>
> new file mode 100644<br>
> index 0000000..144a306<br>
> --- /dev/null<br>
> +++ b/tests/spec/arb_post_depth_coverage/CMakeLists.txt<br>
> @@ -0,0 +1 @@<br>
> +piglit_include_target_api()<br>
> diff --git a/tests/spec/arb_post_depth_coverage/basic.c b/tests/spec/arb_post_depth_coverage/basic.c<br>
> new file mode 100644<br>
> index 0000000..d230e6c<br>
> --- /dev/null<br>
> +++ b/tests/spec/arb_post_depth_coverage/basic.c<br>
> @@ -0,0 +1,237 @@<br>
> +/*<br>
> + * Copyright (c) 2015 Intel Corporation.<br>
> + *<br>
> + * Permission is hereby granted, free of charge, to any person obtaining a<br>
> + * copy of this software and associated documentation files (the "Software"),<br>
> + * to deal in the Software without restriction, including without limitation<br>
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
> + * and/or sell copies of the Software, and to permit persons to whom the<br>
> + * Software is furnished to do so, subject to the following conditions:<br>
> + *<br>
> + * The above copyright notice and this permission notice (including the next<br>
> + * paragraph) shall be included in all copies or substantial portions of the<br>
> + * Software.<br>
> + *<br>
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL<br>
> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
> + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
> + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER<br>
> + * DEALINGS IN THE SOFTWARE.<br>
> + */<br>
> +<br>
> +#include "piglit-util-gl.h"<br>
> +<br>
> +PIGLIT_GL_TEST_CONFIG_BEGIN<br>
> + config.supports_gl_compat_version = 45;<br>
> + config.supports_gl_core_version = 45;</p>
<p dir="ltr">Do we really need to require 4.5? The extension doesn't have any required version.</p>
<p dir="ltr">> + config.window_width = 160;<br>
> + config.window_height = 160;<br>
> + config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DEPTH | PIGLIT_GL_VISUAL_DOUBLE;<br>
> +PIGLIT_GL_TEST_CONFIG_END<br>
> +<br>
> +static GLuint prog1, prog2, vao, ssbo;<br>
> +static GLint *sample_mask;<br>
> +<br>
> +static const char *vs_text =<br>
> + "#version 430\n"<br>
> + "in vec4 pos_in;\n"<br>
> + "void main()\n"<br>
> + "{\n"<br>
> + " gl_Position = pos_in;\n"<br>
> + "}\n";<br>
> +<br>
> +static const char *fs_text1 =<br>
> + "#version 430\n"<br>
> + "out vec4 color;\n"<br>
> + "void main()\n"<br>
> + "{\n"<br>
> + " gl_FragDepth = 0.5f;\n"<br>
> + " color = vec4(0.0, 1.0, 0.0, 1.0);\n"<br>
> + "}\n";<br>
> +<br>
> +static const char *fs_text2 =<br>
> + "#version 430\n"</p>
<p dir="ltr">Are you missing a #extension here? That may indicate that you missed a compiler bit in mesa to grab and check for the extension enable.</p>
<p dir="ltr">> + "out vec4 color;\n"<br>
> + "layout(early_fragment_tests) in;\n"<br>
> + "layout(post_depth_coverage) in;\n"<br>
> + "layout(location = 2) uniform int width;"<br>
> + "layout(std430, binding = 3) buffer MaskOutput {"<br>
> + " int data[];"<br>
> + "} mask_output;"<br>
> + "void main()\n"<br>
> + "{\n"<br>
> + " int index = int(gl_FragCoord.y) * width + int(gl_FragCoord.x);\n"<br>
> + " mask_output.data[index] = int(gl_SampleMaskIn[0]);\n"<br>
> + " color = vec4(1.0, 0.0, 0.0, 1.0);\n"<br>
> + "}\n";<br>
> +<br>
> +static GLuint<br>
> +make_shader_program1(void)<br>
> +{<br>
> + GLuint prog;<br>
> +<br>
> + prog = piglit_build_simple_program(vs_text, fs_text1);<br>
> + glUseProgram(prog);<br>
> +<br>
> + glBindAttribLocation(prog, 0, "pos_in");<br>
> +<br>
> + glLinkProgram(prog);<br>
> +<br>
> + if (!piglit_check_gl_error(GL_NO_ERROR)) {<br>
> + piglit_report_result(PIGLIT_FAIL);<br>
> + }<br>
> +<br>
> + return prog;<br>
> +}<br>
> +<br>
> +static GLuint<br>
> +make_shader_program2(void)<br>
> +{<br>
> + GLuint prog;<br>
> +<br>
> + prog = piglit_build_simple_program(vs_text, fs_text2);<br>
> + glUseProgram(prog);<br>
> +<br>
> + glBindAttribLocation(prog, 0, "pos_in");<br>
> +<br>
> + glLinkProgram(prog);<br>
> +<br>
> + if (!piglit_check_gl_error(GL_NO_ERROR)) {<br>
> + piglit_report_result(PIGLIT_FAIL);<br>
> + }<br>
> +<br>
> + return prog;<br>
> +}<br>
> +<br>
> +<br>
> +static GLuint<br>
> +make_ssbo(void)<br>
> +{<br>
> + GLuint ssbo;<br>
> + glGenBuffers(1, &ssbo);<br>
> + glBindBuffer(GL_SHADER_STORAGE_BUFFER, ssbo);<br>
> +<br>
> + if (!piglit_check_gl_error(GL_NO_ERROR)) {<br>
> + piglit_report_result(PIGLIT_FAIL);<br>
> + }<br>
> +<br>
> + return ssbo;<br>
> +}<br>
> +<br>
> +static GLuint<br>
> +make_vao(void)<br>
> +{<br>
> + static const float pos_tc[12][2] = {<br>
> + { -1.0, -1.0 },<br>
> + { 0.0, -1.0 },<br>
> + { 0.0, 1.0 },<br>
> + { 0.0, 1.0 },<br>
> + { -1.0, 1.0 },<br>
> + { -1.0, -1.0 },<br>
> + { -1.0, -1.0 },<br>
> + { 1.0, -1.0 },<br>
> + { 1.0, 1.0 },<br>
> + { 1.0, 1.0 },<br>
> + { -1.0, 1.0 },<br>
> + { -1.0, -1.0 }<br>
> + };<br>
> + const int stride = sizeof(pos_tc[0]);<br>
> + GLuint vbo, vao;<br>
> +<br>
> + glGenVertexArrays(1, &vao);<br>
> + glBindVertexArray(vao);<br>
> +<br>
> + glGenBuffers(1, &vbo);<br>
> + glBindBuffer(GL_ARRAY_BUFFER, vbo);<br>
> + glBufferData(GL_ARRAY_BUFFER, sizeof(pos_tc), pos_tc, GL_STATIC_DRAW);<br>
> + piglit_check_gl_error(GL_NO_ERROR);<br>
> +<br>
> + glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, stride, (void *) 0);<br>
> +<br>
> + glEnableVertexAttribArray(0);<br>
> +<br>
> + if (!piglit_check_gl_error(GL_NO_ERROR)) {<br>
> + piglit_report_result(PIGLIT_FAIL);<br>
> + }<br>
> +<br>
> + return vbo;<br>
> +}<br>
> +<br>
> +<br>
> +void<br>
> +piglit_init(int argc, char **argv)<br>
> +{<br>
> + piglit_require_gl_version(45);</p>
<p dir="ltr">The test preamble you declared at the top will do the version check for you.</p>
<p dir="ltr">> + piglit_require_extension("GL_ARB_post_depth_coverage");<br>
> + prog1 = make_shader_program1();<br>
> + prog2 = make_shader_program2();<br>
> + vao = make_vao();<br>
> + ssbo = make_ssbo();<br>
> +}<br>
> +<br>
> +<br>
> +enum piglit_result<br>
> +piglit_display(void)<br>
> +{<br>
> + float green[4] = {0.0, 1.0, 0.0, 1.0};<br>
> + float red[4] = {1.0, 0.0, 0.0, 1.0};<br>
> + bool pass = true;<br>
> + int i, j;<br>
> +<br>
> + glEnable(GL_DEPTH_TEST);<br>
> + glViewport(0, 0, piglit_width, piglit_height);<br>
> + sample_mask = (GLint*) malloc (sizeof(GLint) * (piglit_width * piglit_height));<br>
> + for (i = 0; i < piglit_width * piglit_height; i++) {<br>
> + sample_mask[i] = 0;<br>
> + }<br>
> + glBufferData(GL_SHADER_STORAGE_BUFFER, sizeof(GLint) * (piglit_width *<br>
> + piglit_height), &sample_mask[0], GL_DYNAMIC_COPY);<br>
> + glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, ssbo);<br>
> +<br>
> + glClearColor(0.0, 0.0, 0.0, 1.0);<br>
> + glEnable(GL_DEPTH_TEST);<br>
> + glEnable(GL_STENCIL_TEST);<br>
> + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);<br>
> + glUseProgram(prog1);<br>
> + glStencilFunc(GL_ALWAYS, 1, 0xFF);<br>
> + glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);<br>
> + glDrawArrays(GL_TRIANGLES, 0, 6);<br>
> + glUseProgram(prog2);<br>
> + glStencilFunc(GL_NOTEQUAL, 1, 0xFF);<br>
> + glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);<br>
> + glUniform1i(2, piglit_width);<br>
> + glDrawArrays(GL_TRIANGLES, 6, 6);<br>
> +<br>
> + glMemoryBarrier(GL_BUFFER_UPDATE_BARRIER_BIT);</p>
<p dir="ltr">If you're using getBufferSubData I don't think you need this.</p>
<p dir="ltr">> + glGetBufferSubData(GL_SHADER_STORAGE_BUFFER, 0, sizeof(GLint) *<br>
> + piglit_width * piglit_height, &sample_mask[0]);<br>
> +<br>
> + for (i = 0; i < piglit_width; i++) {<br>
> + for (j = 0; j < piglit_height; j++) {<br>
> + if (i >= piglit_width / 2) {<br>
> + if (sample_mask[piglit_width * j + i] != 1) {<br>
> + pass = false;<br>
> + break;<br>
> + }<br>
> + } else {<br>
> + if (sample_mask[piglit_width * j + i] != 0) {<br>
> + pass = false;<br>
> + break;<br>
> + }<br>
> + }<br>
> + }<br>
> + }<br>
> +<br>
> + pass = piglit_probe_rect_rgba(0, 0, piglit_width / 2, piglit_height,<br>
> + green) && pass;<br>
> + pass = piglit_probe_rect_rgba(piglit_width / 2, 0, piglit_width / 2,<br>
> + piglit_height, red) && pass;<br>
> + piglit_present_results();<br>
> +<br>
> + pass = piglit_check_gl_error(GL_NO_ERROR) && pass;<br>
> +<br>
> + free(sample_mask);<br>
> + return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
> +}<br>
> --<br>
> 2.7.4<br>
><br>
> _______________________________________________<br>
> Piglit mailing list<br>
> <a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
> <a href="https://lists.freedesktop.org/mailman/listinfo/piglit">https://lists.freedesktop.org/mailman/listinfo/piglit</a><br></p>