<div dir="ltr">Sorry for this. It is not formatted version.</div><br><div class="gmail_quote"><div dir="ltr">On Wed, Nov 14, 2018 at 2:02 PM Illia Iorin <<a href="mailto:illia.iorin@gmail.com">illia.iorin@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This test checks how GL_ARB_indirect_parameters works<br>
with GL_NV_conditional_render by calling<br>
glMultiDrawArraysIndirectCountARB into conditional<br>
render block.<br>
Detailed explanation of first run_subtest call:<br>
Test tries to draw 10 point, but indirect parametr has to<br>
block it on 5-th draw and block next 5 calls.<br>
<br>
Signed-off-by: Illia Iorin <<a href="mailto:illia.iorin@gloaballogic.com" target="_blank">illia.iorin@gloaballogic.com</a>><br>
---<br>
 tests/opengl.py                               |   1 +<br>
 .../arb_indirect_parameters/CMakeLists.gl.txt |   1 +<br>
 .../conditional-render.c                      | 174 ++++++++++++++++++<br>
 3 files changed, 176 insertions(+)<br>
 create mode 100644 tests/spec/arb_indirect_parameters/conditional-render.c<br>
<br>
diff --git a/tests/opengl.py b/tests/opengl.py<br>
index c672fdad4..1f22fdb14 100644<br>
--- a/tests/opengl.py<br>
+++ b/tests/opengl.py<br>
@@ -4854,6 +4854,7 @@ with profile.test_list.group_manager(<br>
         grouptools.join('spec', 'ARB_indirect_parameters')) as g:<br>
     g(['arb_indirect_parameters-tf-count-arrays'], 'tf-count-arrays')<br>
     g(['arb_indirect_parameters-tf-count-elements'], 'tf-count-elements')<br>
+    g(['arb_indirect_parameters-conditional-render'], 'conditional-render')<br>
<br>
 with profile.test_list.group_manager(<br>
         PiglitGLTest,<br>
diff --git a/tests/spec/arb_indirect_parameters/CMakeLists.gl.txt b/tests/spec/arb_indirect_parameters/CMakeLists.gl.txt<br>
index 88f533d85..5c03835cb 100644<br>
--- a/tests/spec/arb_indirect_parameters/CMakeLists.gl.txt<br>
+++ b/tests/spec/arb_indirect_parameters/CMakeLists.gl.txt<br>
@@ -11,3 +11,4 @@ link_libraries (<br>
<br>
 piglit_add_executable (arb_indirect_parameters-tf-count-elements tf-count-elements.c)<br>
 piglit_add_executable (arb_indirect_parameters-tf-count-arrays tf-count-arrays.c)<br>
+piglit_add_executable (arb_indirect_parameters-conditional-render conditional-render.c)<br>
diff --git a/tests/spec/arb_indirect_parameters/conditional-render.c b/tests/spec/arb_indirect_parameters/conditional-render.c<br>
new file mode 100644<br>
index 000000000..a0dc99355<br>
--- /dev/null<br>
+++ b/tests/spec/arb_indirect_parameters/conditional-render.c<br>
@@ -0,0 +1,174 @@<br>
+/*<br>
+ * Copyright (C) 2018 Illia Iorin<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>
+<br>
+       config.supports_gl_core_version = 32;<br>
+       config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;<br>
+       config.khr_no_error_support = PIGLIT_NO_ERRORS;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+static unsigned const point_count = 10;<br>
+static unsigned const pass_count = 4;<br>
+static GLuint prog_vs_atomic, prog_indr, draw_vao, q, atomic_bo;<br>
+<br>
+static const char vs_indr[] =<br>
+       "#version 140\n"<br>
+       "in vec4 piglit_vertex;\n"<br>
+       "void main()\n"<br>
+       "{\n"<br>
+       "       gl_Position = piglit_vertex;\n"<br>
+       "}\n"<br>
+       ;<br>
+<br>
+static const char fs_indr[] =<br>
+       "#version 140\n"<br>
+       "void main()\n"<br>
+       "{\n"<br>
+       "       gl_FragColor = vec4(1);\n"<br>
+       "}\n"<br>
+       ;<br>
+<br>
+static const char vs_atom[] =<br>
+       "#version 150\n"<br>
+       "#extension GL_ARB_shader_atomic_counters: require\n"<br>
+       "\n"<br>
+       "layout(binding = 0, offset = 0) uniform atomic_uint counter;\n"<br>
+       "\n"<br>
+       "void main() {\n"<br>
+       "       atomicCounterIncrement(counter);\n"<br>
+       "       gl_Position = vec4(0);\n"<br>
+       "}\n"<br>
+       ;<br>
+<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+       GLuint vbo, dbo, xfb_buf;<br>
+       const int in_param[]= {4};<br>
+       float point[] = {0.5, 0.5};<br>
+       const unsigned cmds[] = {1, 1, 0, 0};<br>
+<br>
+       piglit_require_extension("GL_ARB_indirect_parameters");<br>
+       piglit_require_extension("GL_NV_conditional_render");<br>
+<br>
+       prog_indr = piglit_build_simple_program(vs_indr, fs_indr);<br>
+       prog_vs_atomic = piglit_build_simple_program(vs_atom, NULL);<br>
+<br>
+       glGenVertexArrays(1, &draw_vao);<br>
+       glBindVertexArray(draw_vao);<br>
+<br>
+       glGenBuffers(1, &vbo);<br>
+       glBindBuffer(GL_ARRAY_BUFFER, vbo);<br>
+       glBufferData(GL_ARRAY_BUFFER, sizeof(point), point, GL_STATIC_DRAW);<br>
+<br>
+       char *indirect_draw_count_data = malloc(point_count * sizeof(cmds));<br>
+       char *dst = indirect_draw_count_data;<br>
+       for (unsigned i = 0; i < point_count; ++i) {<br>
+               memcpy(dst, cmds, sizeof(cmds));<br>
+               dst += sizeof(cmds);<br>
+       }<br>
+<br>
+       glGenBuffers(1, &atomic_bo);<br>
+       glBindBufferRange(GL_ATOMIC_COUNTER_BUFFER, 0, atomic_bo, 0, 4);<br>
+<br>
+<br>
+       glGenBuffers(1, &dbo);<br>
+       glBindBuffer(GL_DRAW_INDIRECT_BUFFER, dbo);<br>
+       glBufferData(GL_DRAW_INDIRECT_BUFFER, sizeof(cmds)*point_count, indirect_draw_count_data, GL_STATIC_DRAW);<br>
+       free(indirect_draw_count_data);<br>
+<br>
+    glGenBuffers(1, &xfb_buf);<br>
+    glBindBuffer(GL_PARAMETER_BUFFER_ARB, xfb_buf);<br>
+    glBufferData(GL_PARAMETER_BUFFER_ARB, sizeof(in_param), in_param, GL_STATIC_DRAW);<br>
+<br>
+       glGenQueries(1, &q);<br>
+}<br>
+<br>
+enum piglit_result<br>
+run_subtest(bool inverted, bool query_result, unsigned expected_points_count )<br>
+{<br>
+       unsigned result;<br>
+       enum piglit_result subtest_result;<br>
+       char *inverted_s = inverted ? "Yes": "No";<br>
+       char *inverted_s = inverted ? "Yes": "No";<br>
+       char *query_result_s = query_result ? "Pass": "Fail";<br>
+       const unsigned zero = 0;<br>
+<br>
+       glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(zero), &zero, GL_STATIC_DRAW);<br>
+<br>
+       glUseProgram(prog_indr);<br>
+<br>
+       glBeginQuery(GL_ANY_SAMPLES_PASSED, q);<br>
+       if(query_result)<br>
+               piglit_draw_rect(-1, -1, 0.5, 0.5);<br>
+       glEndQuery(GL_ANY_SAMPLES_PASSED);<br>
+<br>
+       glUseProgram(prog_vs_atomic);<br>
+       glEnable(GL_RASTERIZER_DISCARD);<br>
+       if(inverted)<br>
+               glBeginConditionalRenderNV(q, GL_QUERY_WAIT_INVERTED);<br>
+       else<br>
+               glBeginConditionalRenderNV(q, GL_QUERY_WAIT_NV);<br>
+       glMultiDrawArraysIndirectCountARB(GL_POINTS, 0, 0,<br>
+                                         10, 0);<br>
+       glEndConditionalRenderNV();<br>
+       glDisable(GL_RASTERIZER_DISCARD);<br>
+<br>
+       glGetBufferSubData(GL_ATOMIC_COUNTER_BUFFER, 0, sizeof(result), &result);<br>
+       glBufferData(GL_ATOMIC_COUNTER_BUFFER, sizeof(zero), &zero, GL_STATIC_DRAW);<br>
+<br>
+       subtest_result = result == expected_points_count? PIGLIT_PASS : PIGLIT_FAIL;<br>
+<br>
+       piglit_report_subtest_result(subtest_result, "Query result: %s. Inverted mode: %s.  Points drawn: %d",<br>
+          query_result_s, inverted_s, result);<br>
+<br>
+       return subtest_result;<br>
+<br>
+<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       enum piglit_result piglit_test_state = PIGLIT_PASS;<br>
+       enum piglit_result piglit_subtest_state = PIGLIT_PASS;<br>
+<br>
+       piglit_subtest_state = run_subtest(false,true,pass_count);<br>
+       piglit_merge_result(&piglit_test_state, piglit_subtest_state);<br>
+<br>
+       piglit_subtest_state = run_subtest(true,false,pass_count);<br>
+       piglit_merge_result(&piglit_test_state, piglit_subtest_state);<br>
+<br>
+       piglit_subtest_state = run_subtest(true,true,0);<br>
+       piglit_merge_result(&piglit_test_state, piglit_subtest_state);<br>
+<br>
+       piglit_subtest_state = run_subtest(false,false,0);<br>
+       piglit_merge_result(&piglit_test_state, piglit_subtest_state);<br>
+<br>
+       return piglit_test_state;<br>
+}<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div>