On 12 June 2012 12:42, Anuj Phogat <span dir="ltr"><<a href="mailto:anuj.phogat@gmail.com" target="_blank">anuj.phogat@gmail.com</a>></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">
Test assumes that MSAA accuracy test already passes.<br>
<br>
Signed-off-by: Anuj Phogat <<a href="mailto:anuj.phogat@gmail.com">anuj.phogat@gmail.com</a>><br></blockquote><div><br>My comments on the previous patch apply to this one as well. Assuming they are addressed,<br><br>
Reviewed-by: Paul Berry <<a href="mailto:stereotype441@gmail.com">stereotype441@gmail.com</a>><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>
tests/all.tests | 6 +<br>
.../ext_framebuffer_multisample/CMakeLists.gl.txt | 1 +<br>
.../polygon-stipple.cpp | 271 ++++++++++++++++++++<br>
3 files changed, 278 insertions(+), 0 deletions(-)<br>
create mode 100644 tests/spec/ext_framebuffer_multisample/polygon-stipple.cpp<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index 10c5351..bb9bd00 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -1385,6 +1385,12 @@ 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>
+ test_name = ' '.join(['polygon-stipple', str(num_samples)])<br>
+ executable = 'ext_framebuffer_multisample-{0} -auto'.format(<br>
+ test_name)<br>
+ ext_framebuffer_multisample[test_name] = PlainExecTest(executable)<br>
+<br>
ext_framebuffer_object = Group()<br>
spec['EXT_framebuffer_object'] = ext_framebuffer_object<br>
add_fbo_stencil_tests(ext_framebuffer_object, 'GL_STENCIL_INDEX1')<br>
diff --git a/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt b/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt<br>
index 68fed48..78abd5b 100644<br>
--- a/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt<br>
+++ b/tests/spec/ext_framebuffer_multisample/CMakeLists.gl.txt<br>
@@ -23,6 +23,7 @@ piglit_add_executable (ext_framebuffer_multisample-negative-mismatched-samples n<br>
piglit_add_executable (ext_framebuffer_multisample-negative-readpixels negative-readpixels.c)<br>
piglit_add_executable (ext_framebuffer_multisample-point-smooth common.cpp point-smooth.cpp)<br>
piglit_add_executable (ext_framebuffer_multisample-polygon-smooth common.cpp polygon-smooth.cpp)<br>
+piglit_add_executable (ext_framebuffer_multisample-polygon-stipple common.cpp polygon-stipple.cpp)<br>
piglit_add_executable (ext_framebuffer_multisample-renderbuffer-samples renderbuffer-samples.c)<br>
piglit_add_executable (ext_framebuffer_multisample-renderbufferstorage-samples renderbufferstorage-samples.c)<br>
piglit_add_executable (ext_framebuffer_multisample-samples samples.c)<br>
diff --git a/tests/spec/ext_framebuffer_multisample/polygon-stipple.cpp b/tests/spec/ext_framebuffer_multisample/polygon-stipple.cpp<br>
new file mode 100644<br>
index 0000000..c9368a3<br>
--- /dev/null<br>
+++ b/tests/spec/ext_framebuffer_multisample/polygon-stipple.cpp<br>
@@ -0,0 +1,271 @@<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 "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 DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+#include "common.h"<br>
+<br>
+/**<br>
+ * \file polygon-stipple.cpp<br>
+ *<br>
+ * This test case just verifies the functionality of polygon stipple in<br>
+ * multisample FBO and assumes that MSAA accuracy test already passes.<br>
+ * Polygon stipple is expected to work exactly the same way on multisample<br>
+ * FBO as it works on a single sample FBO.<br>
+ *<br>
+ * This test operates by drawing a test pattern with GL_POLYGON_STIPPLE<br>
+ * enabled. Test pattern is first drawn in a single sample FBO to generate<br>
+ * a reference image in right half of default framebuffer.<br>
+ *<br>
+ * Draw the same test pattern in multisample buffer with GL_POLYGON_STIPPLE<br>
+ * enabled. Blit it in to left half of window system framebuffer.<br>
+ * This is the test image.<br>
+ *<br>
+ * Verify the accuracy of polygon stippling in multisample buffer by<br>
+ * comparing the two halves of default framebuffer.<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;<br>
+const int pattern_width = 256; const int pattern_height = 256;<br>
+<br>
+static Fbo ms_fbo, resolve_fbo;<br>
+static GLint num_samples;<br>
+static GLbitfield buffer_to_test;<br>
+<br>
+static const float bg_color[4] =<br>
+ {0.0, 0.0, 1.0, 1.0};<br>
+<br>
+static const float color[4][4] = {<br>
+ /* Red */<br>
+ {1.0, 0.0, 0.0, 1.0},<br>
+ /* Green */<br>
+ {0.0, 1.0, 0.0, 1.0},<br>
+ /* Yellow */<br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char *vert =<br>
+ "#version 130\n"<br>
+ "in vec2 pos;\n"<br>
+ "uniform float depth;\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " vec4 eye_pos = gl_ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0);\n"<br>
+ " gl_Position = vec4(eye_pos.xy, depth, 1.0);\n"<br>
+ "}\n";<br>
+<br>
+static const char *frag =<br>
+ "#version 130\n"<br>
+ "uniform vec4 color;\n"<br>
+ "void main()\n"<br>
+ "{\n"<br>
+ " gl_FragColor = color;\n"<br>
+ "}\n";<br>
+<br>
+void<br>
+shader_compile()<br>
+{<br>
+ /* Compile program */<br>
+ GLint vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vert);<br>
+ GLint fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, frag);<br>
+ prog = piglit_link_simple_program(vs, fs);<br>
+<br>
+ if (!piglit_link_check_status(prog)) {<br>
+ piglit_report_result(PIGLIT_FAIL);<br>
+ }<br>
+<br>
+ glBindAttribLocation(prog, 0, "pos");<br>
+ glEnableVertexAttribArray(0);<br>
+<br>
+ /* Set up uniforms */<br>
+ glUseProgram(prog);<br>
+ color_loc = glGetUniformLocation(prog, "color");<br>
+ depth_loc = glGetUniformLocation(prog, "depth");<br>
+}<br>
+<br>
+void<br>
+draw_pattern(void)<br>
+{<br>
+ float vertex_data[10][2] = {<br>
+ { 0, 0 },<br>
+ { 0, pattern_height },<br>
+ { pattern_width / 4, pattern_height },<br>
+ { pattern_width / 4, 0 },<br>
+ { pattern_width / 2, pattern_height },<br>
+ { pattern_width / 2, 0 },<br>
+ { 3 * pattern_width / 4, pattern_height },<br>
+ { 3 * pattern_width / 4, 0 },<br>
+ { pattern_width, pattern_height },<br>
+ { pattern_width, 0 },<br>
+ };<br>
+<br>
+ unsigned int indices[24] = {0, 1, 2, 0, 2, 3,<br>
+ 3, 2, 4, 3, 4, 5,<br>
+ 5, 4, 6, 5, 6, 7,<br>
+ 7, 6, 8, 7, 8, 9};<br>
+ glUseProgram(prog);<br>
+ glClearColor(bg_color[0], bg_color[1],<br>
+ bg_color[2], bg_color[3]);<br>
+ glClear(buffer_to_test);<br>
+<br>
+ glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, sizeof(vertex_data[0]),<br>
+ (void *) vertex_data);<br>
+ glUniform1f(depth_loc, 0.0);<br>
+<br>
+ for (int i = 0; i < 4; ++i) {<br>
+ glUniform4fv(color_loc, 1, color[i]);<br>
+ glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_INT,<br>
+ (void *) (indices + 6 * i));<br>
+ }<br>
+}<br>
+<br>
+bool<br>
+test_polygon_stipple()<br>
+{<br>
+ bool result = true;<br>
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, ms_fbo.handle);<br>
+ draw_pattern();<br>
+<br>
+ /* Blit ms_fbo to resolve_fbo to resolve multisample buffer */<br>
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, ms_fbo.handle);<br>
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolve_fbo.handle);<br>
+ glBlitFramebuffer(0, 0, pattern_width, pattern_height,<br>
+ 0, 0, pattern_width, pattern_height,<br>
+ buffer_to_test, GL_NEAREST);<br>
+<br>
+ /* Blit resolve_fbo to the left half of window system framebuffer.<br>
+ * This is the test image.<br>
+ */<br>
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_fbo.handle);<br>
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);<br>
+ glBlitFramebuffer(0, 0, pattern_width, pattern_height,<br>
+ 0, 0, pattern_width, pattern_height,<br>
+ buffer_to_test, GL_NEAREST);<br>
+<br>
+ /* Check that the left and right halves of the screen match */<br>
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);<br>
+ result = piglit_probe_rect_halves_equal_rgba(0, 0, piglit_width,<br>
+ piglit_height)<br>
+ && result;<br>
+<br>
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);<br>
+ result = piglit_check_gl_error(GL_NO_ERROR) && result;<br>
+ return result;<br>
+}<br>
+<br>
+void<br>
+print_usage_and_exit(char *prog_name)<br>
+{<br>
+ printf("Usage: %s <num_samples>\n", prog_name);<br>
+ piglit_report_result(PIGLIT_FAIL);<br>
+}<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+ if (argc < 2)<br>
+ print_usage_and_exit(argv[0]);<br>
+ {<br>
+ char *endptr = NULL;<br>
+ num_samples = strtol(argv[1], &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_ortho_projection(pattern_width, pattern_height, GL_TRUE);<br>
+<br>
+ /* Skip the test if num_samples > GL_MAX_SAMPLES or num_samples = 0 */<br>
+ GLint max_samples;<br>
+ glGetIntegerv(GL_MAX_SAMPLES, &max_samples);<br>
+ if (num_samples > max_samples ||<br>
+ num_samples == 0)<br>
+ piglit_report_result(PIGLIT_SKIP);<br>
+<br>
+ ms_fbo.setup(FboConfig(num_samples, pattern_width, pattern_height));<br>
+ resolve_fbo.setup(FboConfig(0, pattern_width, pattern_height));<br>
+<br>
+ buffer_to_test = GL_COLOR_BUFFER_BIT;<br>
+ shader_compile();<br>
+ glEnable(GL_POLYGON_STIPPLE);<br>
+ glPolygonStipple(stipple_pattern);<br>
+<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display()<br>
+{<br>
+ bool pass = true;<br>
+ glClearColor(0.0, 0.0, 0.0, 1.0);<br>
+ glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+ /* Draw test pattern in single sample resolve_fbo with GL_POLYGON_STIPPLE<br>
+ * enabled.<br>
+ */<br>
+ glBindFramebuffer(GL_DRAW_FRAMEBUFFER, resolve_fbo.handle);<br>
+ resolve_fbo.set_viewport();<br>
+ draw_pattern();<br>
+<br>
+ /* Blit resolve_fbo to the right half of window system framebuffer. This<br>
+ * is a reference image.<br>
+ */<br>
+ glBindFramebuffer(GL_READ_FRAMEBUFFER, resolve_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>
+ buffer_to_test, GL_NEAREST);<br>
+<br>
+ /* Test with multisample FBO and GL_POLYGON_STIPPLE enabled */<br>
+ pass = test_polygon_stipple() && pass;<br>
+<br>
+ if (!piglit_automatic &&<br>
+ buffer_to_test != GL_DEPTH_BUFFER_BIT)<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>