Pushed, thanks.<br><br>Marek<br><br><div class="gmail_quote">On Thu, Mar 31, 2011 at 12:08 AM, Julian Adams <span dir="ltr">&lt;<a href="mailto:joolsa@gmail.com">joolsa@gmail.com</a>&gt;</span> wrote:<br><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                       |    1 +<br>
 tests/fbo/CMakeLists.gl.txt           |    1 +<br>
 tests/fbo/fbo-drawbuffers-blend-add.c |  251 +++++++++++++++++++++++++++++++++<br>
 3 files changed, 253 insertions(+), 0 deletions(-)<br>
 create mode 100644 tests/fbo/fbo-drawbuffers-blend-add.c<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index c2c58ae..eb86ae7 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -130,6 +130,7 @@ add_plain_test(fbo, &#39;fbo-depthtex&#39;)<br>
 add_plain_test(fbo, &#39;fbo-depth-sample-compare&#39;)<br>
 add_plain_test(fbo, &#39;fbo-drawbuffers&#39;)<br>
 add_plain_test(fbo, &#39;fbo-drawbuffers-arbfp&#39;)<br>
+add_plain_test(fbo, &#39;fbo-drawbuffers-blend-add&#39;)<br>
 add_plain_test(fbo, &#39;fbo-drawbuffers-fragcolor&#39;)<br>
 add_plain_test(fbo, &#39;fbo-drawbuffers-maxtargets&#39;)<br>
 add_plain_test(fbo, &#39;fbo-drawbuffers2-blend&#39;)<br>
diff --git a/tests/fbo/CMakeLists.gl.txt b/tests/fbo/CMakeLists.gl.txt<br>
index 819d5cf..999c0c4 100644<br>
--- a/tests/fbo/CMakeLists.gl.txt<br>
+++ b/tests/fbo/CMakeLists.gl.txt<br>
@@ -36,6 +36,7 @@ add_executable (fbo-clearmipmap fbo-clearmipmap.c)<br>
 add_executable (fbo-clear-formats fbo-clear-formats.c)<br>
 add_executable (fbo-drawbuffers fbo-drawbuffers.c)<br>
 add_executable (fbo-drawbuffers-arbfp fbo-drawbuffers-arbfp.c)<br>
+add_executable (fbo-drawbuffers-blend-add fbo-drawbuffers-blend-add.c)<br>
 add_executable (fbo-drawbuffers-fragcolor fbo-drawbuffers-fragcolor.c)<br>
 add_executable (fbo-drawbuffers-maxtargets fbo-drawbuffers-maxtargets.c)<br>
 add_executable (fbo-drawbuffers2-blend fbo-drawbuffers2-blend.c)<br>
diff --git a/tests/fbo/fbo-drawbuffers-blend-add.c b/tests/fbo/fbo-drawbuffers-blend-add.c<br>
new file mode 100644<br>
index 0000000..d6fce41<br>
--- /dev/null<br>
+++ b/tests/fbo/fbo-drawbuffers-blend-add.c<br>
@@ -0,0 +1,251 @@<br>
+/*<br>
+ * Copyright © 2010 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>
+ * Authors:<br>
+ *       Eric Anholt &lt;<a href="mailto:eric@anholt.net">eric@anholt.net</a>&gt;<br>
+ *       Marek Olšák &lt;<a href="mailto:maraeo@gmail.com">maraeo@gmail.com</a>&gt;<br>
+ *<br>
+ */<br>
+<br>
+/** @file fbo-drawbuffers-blend-add.c<br>
+ *<br>
+ * Tests that additive blending is enabled for all render targets with ARB_draw_buffers.<br>
+ */<br>
+<br>
+#include &lt;string.h&gt;<br>
+#include &quot;piglit-util.h&quot;<br>
+<br>
+int piglit_width = 256;<br>
+int piglit_height = 256;<br>
+int piglit_window_mode = GLUT_RGB | GLUT_ALPHA | GLUT_DOUBLE;<br>
+<br>
+static GLint max_targets;<br>
+<br>
+static char *vs_source =<br>
+       &quot;void main()\n&quot;<br>
+       &quot;{\n&quot;<br>
+       &quot;       gl_Position = gl_Vertex;\n&quot;<br>
+       &quot;}\n&quot;;<br>
+<br>
+static char *fs_source_start =<br>
+       &quot;void main()\n&quot;<br>
+       &quot;{\n&quot;;<br>
+<br>
+static char *fs_source_output =<br>
+       &quot;       gl_FragData[%d].xyzw = vec4(%f, %f, %f, %f);\n&quot;;<br>
+<br>
+static char *fs_source_end =<br>
+       &quot;}\n&quot;;<br>
+<br>
+float output_values[] = {<br>
+       0.0, 0.5, 0.0, 0.0,<br>
+       0.0, 0.0, 0.5, 0.0,<br>
+       0.0, 0.5, 0.5, 0.0,<br>
+       0.5, 0.5, 0.0, 0.0,<br>
+<br>
+       0.0, 0.5, 0.0, 0.5,<br>
+       0.0, 0.0, 0.5, 0.5,<br>
+       0.0, 0.5, 0.5, 0.5,<br>
+       0.5, 0.5, 0.0, 0.5,<br>
+<br>
+       0.0, 0.25, 0.0, 0.0,<br>
+       0.0, 0.0, 0.25, 0.0,<br>
+       0.0, 0.25, 0.25, 0.0,<br>
+       0.25, 0.25, 0.0, 0.0,<br>
+<br>
+       0.0, 0.25, 0.0, 0.25,<br>
+       0.0, 0.0, 0.25, 0.25,<br>
+       0.0, 0.25, 0.25, 0.25,<br>
+       0.25, 0.25, 0.0, 0.25};<br>
+<br>
+float clear_value = 0.25;<br>
+<br>
+static GLuint<br>
+attach_texture(int i)<br>
+{<br>
+       GLuint tex;<br>
+<br>
+       glGenTextures(1, &amp;tex);<br>
+       glBindTexture(GL_TEXTURE_2D, tex);<br>
+       glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,<br>
+                        32, 32, 0,<br>
+                        GL_RGBA, GL_UNSIGNED_BYTE, NULL);<br>
+<br>
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);<br>
+       glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);<br>
+<br>
+       glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,<br>
+                                 GL_COLOR_ATTACHMENT0_EXT + i,<br>
+                                 GL_TEXTURE_2D,<br>
+                                 tex,<br>
+                                 0);<br>
+       assert(glGetError() == 0);<br>
+<br>
+       return tex;<br>
+}<br>
+<br>
+static void<br>
+generate_and_display_drawbuffers(int count)<br>
+{<br>
+       GLuint tex[16], fb, fs, vs, prog;<br>
+       GLenum attachments[16], status;<br>
+       int i;<br>
+<br>
+       glGenFramebuffersEXT(1, &amp;fb);<br>
+       glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb);<br>
+<br>
+       for (i = 0; i &lt; count; i++) {<br>
+               tex[i] = attach_texture(i);<br>
+               attachments[i] = GL_COLOR_ATTACHMENT0 + i;<br>
+       }<br>
+<br>
+       status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);<br>
+       if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {<br>
+               fprintf(stderr, &quot;fbo incomplete (status = 0x%04x)\n&quot;, status);<br>
+               piglit_report_result(PIGLIT_SKIP);<br>
+       }<br>
+<br>
+       glDrawBuffersARB(count, attachments);<br>
+<br>
+       /* Clear all to 0.25 so we see if the shader rendering happens. */<br>
+       glClearColor(clear_value, clear_value, clear_value, clear_value);<br>
+       glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+       /* Build the shader that spams green to all outputs. */<br>
+       vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);<br>
+<br>
+       char fs_output_line[256];<br>
+       char fs_full_source[1024];<br>
+<br>
+       strcpy(fs_full_source, fs_source_start);<br>
+<br>
+       for (i = 0; i &lt; count; i++) {<br>
+               sprintf(fs_output_line, fs_source_output, i, output_values[i * 4],<br>
+                               output_values[(i * 4) + 1], output_values[(i * 4) + 2],<br>
+                               output_values[(i * 4) + 3]);<br>
+<br>
+               strcat(fs_full_source, fs_output_line);<br>
+       }<br>
+<br>
+       strcat(fs_full_source, fs_source_end);<br>
+<br>
+       assert(strlen(fs_full_source) + 1 &lt; sizeof(fs_full_source) / sizeof(fs_full_source[0]));<br>
+<br>
+       fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_full_source);<br>
+<br>
+       prog = piglit_link_simple_program(vs, fs);<br>
+       glUseProgram(prog);<br>
+<br>
+       glEnable(GL_BLEND);<br>
+       glBlendFunc(GL_ONE, GL_ONE);<br>
+       glBlendEquation(GL_FUNC_ADD);<br>
+<br>
+       /* Now render to all the color buffers. */<br>
+       piglit_draw_rect(-1, -1, 2, 2);<br>
+<br>
+       glDisable(GL_BLEND);<br>
+<br>
+       /* OK, now draw each of these textures to the winsys framebuffer. */<br>
+       glUseProgram(0);<br>
+       glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);<br>
+       piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);<br>
+       glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);<br>
+       glEnable(GL_TEXTURE_2D);<br>
+       for (i = 0; i &lt; count; i++) {<br>
+               glBindTexture(GL_TEXTURE_2D, tex[i]);<br>
+               piglit_draw_rect_tex(16 * i, 16 * (count - 1),<br>
+                                        16, 16,<br>
+                                        0, 0,<br>
+                                        1, 1);<br>
+       }<br>
+       glDisable(GL_TEXTURE_2D);<br>
+<br>
+       for (i = 0; i &lt; count; i++) {<br>
+               glDeleteTextures(1, &amp;tex[i]);<br>
+       }<br>
+       glDeleteFramebuffersEXT(1, &amp;fb);<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       #define N_VECTOR_ITEMS 4<br>
+       GLboolean pass = GL_TRUE;<br>
+       int count, i, j;<br>
+       float expected[N_VECTOR_ITEMS] = {0};<br>
+<br>
+<br>
+       glClearColor(0.5, 0.5, 0.5, 0.5);<br>
+       glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+       for (count = 1; count &lt;= max_targets; count++) {<br>
+               generate_and_display_drawbuffers(count);<br>
+       }<br>
+<br>
+       for (count = 1; count &lt;= max_targets; count++) {<br>
+               for (i = 0; i &lt; count; i++) {<br>
+                       for (j = 0; j &lt; N_VECTOR_ITEMS; j++) {<br>
+                               expected[j] = output_values[(i * N_VECTOR_ITEMS) + j] +<br>
+                                       clear_value;<br>
+                       }<br>
+<br>
+                       pass = pass &amp;&amp;<br>
+                               piglit_probe_pixel_rgba(16 * i + 8,<br>
+                                                          16 * (count - 1) + 8,<br>
+                                                          expected);<br>
+               }<br>
+       }<br>
+<br>
+       glutSwapBuffers();<br>
+<br>
+       return pass ? PIGLIT_SUCCESS : PIGLIT_FAILURE;<br>
+}<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+       GLint max_attachments;<br>
+<br>
+       printf(&quot;The result should be a rows of boxes of differing colors, \n&quot;<br>
+                  &quot;one for each drawbuffer target used (none black).\n&quot;);<br>
+<br>
+       piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);<br>
+<br>
+       if (!GLEW_VERSION_2_0) {<br>
+               printf(&quot;Requires OpenGL 2.0\n&quot;);<br>
+               piglit_report_result(PIGLIT_SKIP);<br>
+       }<br>
+<br>
+       piglit_require_extension(&quot;GL_EXT_framebuffer_object&quot;);<br>
+       piglit_require_extension(&quot;GL_ARB_draw_buffers&quot;);<br>
+<br>
+       glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &amp;max_targets);<br>
+       if (max_targets &lt; 2)<br>
+               piglit_report_result(PIGLIT_SKIP);<br>
+<br>
+       glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS_EXT, &amp;max_attachments);<br>
+       if (max_targets &gt; max_attachments)<br>
+               max_targets = max_attachments;<br>
+<br>
+       if (max_targets &gt; 16)<br>
+               max_targets = 16;<br>
+}<br>
<font color="#888888">--<br>
1.7.1<br>
<br>
</font><br>_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
<br></blockquote></div><br>