On 18 May 2012 16:56, Anuj Phogat <span dir="ltr">&lt;<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>&gt;</span> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This test varifies that GL_LINE_SMOOTH is ignored in case of multisample<br>
lines.<br>
<br>
Note: Smooth lines and multisampling seems to work fine but this test<br>
is failing on AMD catalyst drivers. Testing on NVIDIA could help.<br></blockquote><div><br>&quot;line-smooth&quot; passes on my nVidia system.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

<br>
Signed-off-by: Anuj Phogat &lt;<a href="mailto:anuj.phogat@gmail.com">anuj.phogat@gmail.com</a>&gt;<br>
---<br>
 tests/all.tests                                    |    7 +<br>
 .../ext_framebuffer_multisample/CMakeLists.gl.txt  |    1 +<br>
 .../ext_framebuffer_multisample/line-smooth.cpp    |  189 ++++++++++++++++++++<br>
 3 files changed, 197 insertions(+), 0 deletions(-)<br>
 create mode 100644 tests/spec/ext_framebuffer_multisample/line-smooth.cpp<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index aaeb809..0332051 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -1336,6 +1336,13 @@ for num_samples in (2, 4, 8, 16, 32):<br>
                         test_name)<br>
                 ext_framebuffer_multisample[test_name] = PlainExecTest(executable)<br>
<br>
+for num_samples in (2, 4, 8, 16, 32):<br>
+        for buffer_type in (&#39;color&#39;, &#39;depth&#39;, &#39;stencil&#39;):<br>
+                test_name = &#39; &#39; .join([&#39;line-smooth&#39;, str(num_samples), buffer_type])<br>
+                executable = &#39;ext_framebuffer_multisample-{0} -auto&#39;.format(<br>
+                        test_name)<br>
+                ext_framebuffer_multisample[test_name] = PlainExecTest(executable)<br>
+<br>
 ext_framebuffer_object = Group()<br>
 spec[&#39;EXT_framebuffer_object&#39;] = ext_framebuffer_object<br>
 add_fbo_stencil_tests(ext_framebuffer_object, &#39;GL_STENCIL_INDEX1&#39;)<br>
diff --git a/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt b/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt<br>
index 475237c..42be35b 100644<br>
--- a/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt<br>
+++ b/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt<br>
@@ -13,6 +13,7 @@ link_libraries (<br>
<br>
 piglit_add_executable (ext_framebuffer_multisample-accuracy common.cpp accuracy.cpp)<br>
 piglit_add_executable (ext_framebuffer_multisample-dlist dlist.c)<br>
+piglit_add_executable (ext_framebuffer_multisample-line-smooth common.cpp line-smooth.cpp)<br>
 piglit_add_executable (ext_framebuffer_multisample-minmax minmax.c)<br>
 piglit_add_executable (ext_framebuffer_multisample-multisample-blit common.cpp multisample-blit.cpp)<br>
 piglit_add_executable (ext_framebuffer_multisample-negative-copypixels negative-copypixels.c)<br>
diff --git a/tests/spec/ext_framebuffer_multisample/line-smooth.cpp b/tests/spec/ext_framebuffer_multisample/line-smooth.cpp<br>
new file mode 100644<br>
index 0000000..d6c55c3<br>
--- /dev/null<br>
+++ b/tests/spec/ext_framebuffer_multisample/line-smooth.cpp<br>
@@ -0,0 +1,189 @@<br>
+/*<br>
+ * Copyright © 2012 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 &quot;Software&quot;),<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 &quot;AS IS&quot;, 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 DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+#include &quot;common.h&quot;<br>
+<br>
+/**<br>
+ * \file line-smooth.cpp<br>
+ *<br>
+ * Page 128 (in the PDF) of the OpenGL 3.0 spec says:<br>
+ * &quot;If MULTISAMPLE is enabled, and the value of SAMPLE BUFFERS is one,<br>
+ * then lines are rasterized using the following algorithm, regardless<br>
+ * of whether line antialias-ing (LINE_SMOOTH) is enabled or disabled&quot;.<br>
+<br>
+ * This test operates by drawing a test pattern with GL_LINE_SMOOTH<br>
+ * disabled. Blit it in to right half of window system framebuffer.<br>
+ * This is our reference image.<br>
+ *<br>
+ * Draw the same test pattern second time with GL_LINE_SMOOTH enabled<br>
+ * in a multisample buffer. Blit it in to left half of window system<br>
+ * framebuffer. This is our test image.<br>
+ *<br>
+ * To verify that GL_LINE_SMOOTH don&#39;t affect MSAA, compare the two<br>
+ * halves of default framebuffer. They are expected to match.<br>
+ *<br>
+ */<br>
+int piglit_width = 512; int piglit_height = 256;<br>
+int piglit_window_mode =<br>
+       GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA | GLUT_DEPTH | GLUT_STENCIL;<br>
+<br>
+const int pattern_width = 256; const int pattern_height = 256;<br>
+<br>
+Fbo test_fbo;<br>
+Fbo dst_fbo;<br>
+TestPattern *test_pattern = NULL;<br>
+ManifestProgram *manifest_program = NULL;<br>
+GLbitfield buffer_to_test;<br>
+<br>
+void<br>
+print_usage_and_exit(char *prog_name)<br>
+{<br>
+       printf(&quot;Usage: %s &lt;num_samples&gt; &lt;buffer_type&gt;\n&quot;<br>
+              &quot;  where &lt;buffer_type&gt; is one of:\n&quot;<br>
+              &quot;    color\n&quot;<br>
+              &quot;    stencil\n&quot;<br>
+              &quot;    depth\n&quot;,<br>
+              prog_name);<br>
+       piglit_report_result(PIGLIT_FAIL);<br>
+}<br></blockquote><div><br>It seems redundant to test smooth lines on color, depth, and stencil buffers, since line smoothing is part of rasterization, which applies uniformly to all attached buffers.  Can we simplify this test to just test with a color buffer?<br>
 </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+       int num_samples;<br>
+       if (argc &lt; 3)<br>
+               print_usage_and_exit(argv[0]);<br>
+       {<br>
+               char *endptr = NULL;<br>
+               num_samples = strtol(argv[1], &amp;endptr, 0);<br>
+               if (endptr != argv[1] + strlen(argv[1]))<br>
+                       print_usage_and_exit(argv[0]);<br>
+       }<br>
+<br>
+       piglit_require_gl_version(30);<br>
+       piglit_require_GLSL_version(130);<br>
+       glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+       /* Skip the test if num_samples &gt; GL_MAX_SAMPLES */<br>
+       GLint max_samples;<br>
+       glGetIntegerv(GL_MAX_SAMPLES, &amp;max_samples);<br>
+       if (num_samples &gt; max_samples)<br>
+               piglit_report_result(PIGLIT_SKIP);<br>
+<br>
+       if (strcmp(argv[2], &quot;color&quot;) == 0) {<br>
+               test_pattern = new Lines();<br>
+               buffer_to_test = GL_COLOR_BUFFER_BIT;<br>
+       } else if (strcmp(argv[2], &quot;depth&quot;) == 0) {<br>
+               test_pattern = new DepthStar();<br>
+               manifest_program = new ManifestDepth();<br>
+               buffer_to_test = GL_DEPTH_BUFFER_BIT;<br>
+       } else if (strcmp(argv[2], &quot;stencil&quot;) == 0) {<br>
+               test_pattern = new StencilStar();<br>
+               manifest_program = new ManifestStencil();<br>
+               buffer_to_test = GL_STENCIL_BUFFER_BIT;<br>
+       } else {<br>
+               print_usage_and_exit(argv[0]);<br>
+       }<br>
+<br>
+       test_pattern-&gt;compile();<br>
+       if (manifest_program)<br>
+               manifest_program-&gt;compile();<br>
+<br>
+       test_fbo.init(num_samples, pattern_width, pattern_height,<br>
+                    true /* combine_depth_stencil */,<br>
+                    false /* attach_texture */);<br>
+<br>
+       glEnable (GL_BLEND);<br>
+       glBlendFunc (GL_SRC_ALPHA_SATURATE, GL_ONE);<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display()<br>
+{<br>
+       bool pass = true;<br>
+       float proj[4][4] = {<br>
+               { 1, 0, 0, 0 },<br>
+               { 0, 1, 0, 0 },<br>
+               { 0, 0, 1, 0 },<br>
+               { 0, 0, 0, 1 } };<br>
+       /* Draw test pattern in  multisample test_fbo with GL_LINE_SMOOTH<br>
+        * disabled.<br>
+        */<br>
+       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, test_fbo.handle);<br>
+       glClear(buffer_to_test);<br>
+       test_fbo.set_viewport();<br>
+       test_pattern-&gt;draw(proj);<br>
+<br>
+       /* Blit test_fbo to the right half of window system framebuffer.<br>
+        * This is the reference image.<br>
+        */<br>
+       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, test_fbo.handle);<br>
+       test_fbo.set_viewport();<br>
+       if (manifest_program)<br>
+               manifest_program-&gt;run();<br>
+       glBindFramebuffer(GL_READ_FRAMEBUFFER, test_fbo.handle);<br>
+       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);<br>
+       glBlitFramebuffer(0, 0, pattern_width, pattern_height,<br>
+                         pattern_width, 0, 2*pattern_width, pattern_height,<br>
+                         GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
+<br>
+       /* Draw test pattern in mulisample test_fbo with GL_LINE_SMOOTH<br>
+        * enabled<br>
+        */<br>
+       glEnable(GL_LINE_SMOOTH);<br>
+       glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);<br>
+       glDisable (GL_DEPTH_TEST);<br></blockquote><div><br>Can you comment on why it&#39;s necessary to disable depth testing here?  It&#39;s not immediately obvious to me.<br> </div><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

+<br>
+       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, test_fbo.handle);<br>
+       test_fbo.set_viewport();<br>
+       test_pattern-&gt;draw(proj);<br>
+<br>
+       glDisable(GL_LINE_SMOOTH);<br>
+<br>
+       /* Now blit test_fbo to the left half of window system framebuffer.<br>
+        * This is the test image.<br>
+        */<br>
+       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, test_fbo.handle);<br>
+       test_fbo.set_viewport();<br>
+       if (manifest_program)<br>
+               manifest_program-&gt;run();<br>
+       glBindFramebuffer(GL_READ_FRAMEBUFFER, test_fbo.handle);<br>
+       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);<br>
+       glBlitFramebuffer(0, 0, pattern_width, pattern_height,<br>
+                         0, 0, pattern_width, pattern_height,<br>
+                         GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
+<br>
+       /* Check that the left and right halves of the screen match. If they<br>
+        * don&#39;t, then GL_LINE_SMOOTH is not ignored with multisample<br>
+        * rendering.<br>
+        */<br>
+       glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);<br>
+       pass = piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width,<br>
+                                                  piglit_height) &amp;&amp; pass;<br>
+<br>
+       pass = piglit_check_gl_error(GL_NO_ERROR) &amp;&amp; pass;<br>
+<br>
+       piglit_present_results();<br>
+<br>
+       return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
<span class="HOEnZb"><font color="#888888">--<br>
1.7.7.6<br>
<br>
_______________________________________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br>