<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sat, Jun 28, 2014 at 6:28 AM, Brian Paul <span dir="ltr"><<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5">On 06/27/2014 05:31 PM, Jason Ekstrand wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
This is a simple sanity test for the ARB_copy_image extension.  This tests<br>
tests the different combinations of textures and renderbuffers for intputs<br>
and outputs to glCopyTexSubImage.<br>
<br>
Signed-off-by: Jason Ekstrand <<a href="mailto:jason.ekstrand@intel.com" target="_blank">jason.ekstrand@intel.com</a>><br>
---<br>
  tests/all.py                                |   6 +<br>
  tests/spec/CMakeLists.txt                   |   1 +<br>
  tests/spec/arb_copy_image/<u></u>CMakeLists.gl.txt |  13 ++<br>
  tests/spec/arb_copy_image/<u></u>CMakeLists.txt    |   1 +<br>
  tests/spec/arb_copy_image/<u></u>simple.c          | 226 ++++++++++++++++++++++++++++<br>
  5 files changed, 247 insertions(+)<br>
  create mode 100644 tests/spec/arb_copy_image/<u></u>CMakeLists.gl.txt<br>
  create mode 100644 tests/spec/arb_copy_image/<u></u>CMakeLists.txt<br>
  create mode 100644 tests/spec/arb_copy_image/<u></u>simple.c<br>
<br>
diff --git a/tests/all.py b/tests/all.py<br>
index 17d5d9b..9e6196e 100644<br>
--- a/tests/all.py<br>
+++ b/tests/all.py<br>
@@ -3110,6 +3110,12 @@ arb_copy_buffer['overlap'] = concurrent_test('arb_copy_<u></u>buffer-overlap')<br>
  arb_copy_buffer['targets'] = concurrent_test('arb_copy_<u></u>buffer-targets')<br>
  arb_copy_buffer['subdata-sync'<u></u>] = concurrent_test('arb_copy_<u></u>buffer-subdata-sync')<br>
<br>
+arb_copy_image = {}<br>
+spec['ARB_copy_image'] = arb_copy_image<br>
+add_concurrent_test(arb_copy_<u></u>image, 'arb_copy_image-simple --tex-to-tex')<br>
+add_concurrent_test(arb_copy_<u></u>image, 'arb_copy_image-simple --rb-to-tex')<br>
+add_concurrent_test(arb_copy_<u></u>image, 'arb_copy_image-simple --rb-to-rb')<br>
+<br>
  arb_half_float_vertex = {}<br>
  spec['ARB_half_float_vertex'] = arb_half_float_vertex<br>
  add_plain_test(arb_half_float_<u></u>vertex, 'draw-vertices-half-float')<br>
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt<br>
index 489ff0c..73fe908 100644<br>
--- a/tests/spec/CMakeLists.txt<br>
+++ b/tests/spec/CMakeLists.txt<br>
@@ -4,6 +4,7 @@ add_subdirectory (arb_buffer_storage)<br>
  add_subdirectory (arb_clear_buffer_object)<br>
  add_subdirectory (arb_clear_texture)<br>
  add_subdirectory (arb_color_buffer_float)<br>
+add_subdirectory (arb_copy_image)<br>
  add_subdirectory (arb_compute_shader)<br>
  add_subdirectory (arb_debug_output)<br>
  add_subdirectory (khr_debug)<br>
diff --git a/tests/spec/arb_copy_image/<u></u>CMakeLists.gl.txt b/tests/spec/arb_copy_image/<u></u>CMakeLists.gl.txt<br>
new file mode 100644<br>
index 0000000..ac8ddcc<br>
--- /dev/null<br>
+++ b/tests/spec/arb_copy_image/<u></u>CMakeLists.gl.txt<br>
@@ -0,0 +1,13 @@<br>
+include_directories(<br>
+       ${GLEXT_INCLUDE_DIR}<br>
+       ${OPENGL_INCLUDE_PATH}<br>
+)<br>
+<br>
+link_libraries (<br>
+       piglitutil_${piglit_target_<u></u>api}<br>
+       ${OPENGL_gl_LIBRARY}<br>
+)<br>
+<br>
+piglit_add_executable (arb_copy_image-simple simple.c)<br>
+<br>
+# vim: ft=cmake:<br>
diff --git a/tests/spec/arb_copy_image/<u></u>CMakeLists.txt b/tests/spec/arb_copy_image/<u></u>CMakeLists.txt<br>
new file mode 100644<br>
index 0000000..144a306<br>
--- /dev/null<br>
+++ b/tests/spec/arb_copy_image/<u></u>CMakeLists.txt<br>
@@ -0,0 +1 @@<br>
+piglit_include_target_api()<br>
diff --git a/tests/spec/arb_copy_image/<u></u>simple.c b/tests/spec/arb_copy_image/<u></u>simple.c<br>
new file mode 100644<br>
index 0000000..f720c26<br>
--- /dev/null<br>
+++ b/tests/spec/arb_copy_image/<u></u>simple.c<br>
@@ -0,0 +1,226 @@<br>
+/*<br>
+ * Copyright 2014 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>
+/** @file simple.c<br>
+ *<br>
+ * A simple test of glCopyImageSubData that copies a square from one<br>
+ * 2D texture to another and back.  This test exercises texture to texture,<br>
+ * texture to renderbuffer, renderbuffer to texture, and renderbuffer to<br>
+ * renderbuffer copies.<br>
+ */<br>
+#include "piglit-util-gl-common.h"<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+       config.supports_gl_compat_<u></u>version = 13;<br>
+<br>
+       config.window_width = 128;<br>
+       config.window_height = 64;<br>
</blockquote>
<br></div></div>
Does the window size really matter?  If not, please omit those lines and use the default.  If the size does matter, please use width >= 160 to allow this to work on Windows.  See the comments in tests/util/piglit-framework-<u></u>gl.h for more info.<div>
<div class="h5"><br></div></div></blockquote><div>Fixed that, thanks.  In this case 160x160 is just fine.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+       config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+static const float green[3] = {0.0, 1.0, 0.0};<br>
+static const float red[3] = {1.0, 0.0, 0.0};<br>
+static const float blue[3] = {0.0, 0.0, 1.0};<br>
+<br>
+int renderbuffers = 0;<br>
+<br>
+void<br>
+piglit_init(int argc, char **argv)<br>
+{<br>
+       int i;<br>
+<br>
+       piglit_require_extension("GL_<u></u>ARB_copy_image");<br>
+       piglit_require_extension("GL_<u></u>EXT_framebuffer_object");<br>
+<br>
+       for (i = 0; i < argc; ++i) {<br>
+               if (strcmp(argv[i], "--tex-to-tex") == 0)<br>
+                       renderbuffers = 0;<br>
+               else if (strcmp(argv[i], "--tex-to-rb") == 0)<br>
+                       renderbuffers = 1;<br>
+               else if (strcmp(argv[i], "--rb-to-rb") == 0)<br>
+                       renderbuffers = 2;<br>
+       }<br>
+}<br>
+<br>
+struct image {<br>
+       GLuint name, fbo;<br>
+       GLenum target;<br>
+};<br>
+<br>
+void<br>
+image_init(struct image *image, GLenum target, GLenum internalformat)<br>
</blockquote>
<br></div></div>
All these local functions should be declared static to avoid compiler warnings.<div><div class="h5"><br></div></div></blockquote><div><br></div><div>done<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><div class="h5">
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+{<br>
+       image->target = target;<br>
+<br>
+       glGenFramebuffersEXT(1, &image->fbo);<br>
+       glBindFramebufferEXT(GL_<u></u>FRAMEBUFFER_EXT, image->fbo);<br>
+<br>
+       if (image->target == GL_RENDERBUFFER_EXT) {<br>
+               glGenRenderbuffersEXT(1, &image->name);<br>
+               glBindRenderbufferEXT(GL_<u></u>RENDERBUFFER, image->name);<br>
+               glRenderbufferStorageEXT(GL_<u></u>RENDERBUFFER_EXT,<br>
+                                        internalformat, 64, 64);<br>
+               glFramebufferRenderbufferEXT(<u></u>GL_FRAMEBUFFER_EXT,<br>
+                                            GL_COLOR_ATTACHMENT0_EXT,<br>
+                                            image->target, image->name);<br>
+       } else {<br>
+               glGenTextures(1, &image->name);<br>
+               glBindTexture(image->target, image->name);<br>
+               glTexImage2D(image->target, 0, internalformat,<br>
+                            64, 64, 0, internalformat, GL_BYTE, NULL);<br>
+               glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);<br>
+               glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);<br>
+               glFramebufferTexture2DEXT(GL_<u></u>FRAMEBUFFER_EXT,<br>
+                                         GL_COLOR_ATTACHMENT0_EXT,<br>
+                                         image->target, image->name, 0);<br>
+       }<br>
+}<br>
+<br>
+void<br>
+image_destroy(struct image *image)<br>
+{<br>
+       if (image->target == GL_RENDERBUFFER_EXT)<br>
+               glDeleteRenderbuffersEXT(1, &image->name);<br>
+       else<br>
+               glDeleteTextures(1, &image->name);<br>
+<br>
+       glDeleteFramebuffers(1, &image->fbo);<br>
+}<br>
+<br>
+void<br>
+image_fill(struct image *image, const float *color)<br>
+{<br>
+       glClearColor(color[0], color[1], color[2], 1.0f);<br>
+       glBindFramebufferEXT(GL_<u></u>FRAMEBUFFER_EXT, image->fbo);<br>
+       glClear(GL_COLOR_BUFFER_BIT);<br>
+}<br>
+<br>
+void<br>
+image_draw(struct image *image, int x, int y)<br>
+{<br>
+       if (image->target == GL_RENDERBUFFER_EXT) {<br>
+               glBindFramebufferEXT(GL_READ_<u></u>FRAMEBUFFER_EXT, image->fbo);<br>
+               glBlitFramebufferEXT(0, 0, 64, 64, x, y, x + 64, y + 64,<br>
+                                    GL_COLOR_BUFFER_BIT, GL_NEAREST);<br>
+       } else {<br>
+               /* Set up or GL environment for rendering */<br>
+               piglit_ortho_projection(<u></u>piglit_width, piglit_height, GL_FALSE);<br>
+               glEnable(GL_TEXTURE_2D);<br>
+               glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);<br>
+<br>
+               glBindTexture(image->target, image->name);<br>
+               piglit_draw_rect_tex(x, y, 64, 64, 0, 0, 1, 1);<br>
+<br>
+               glDisable(GL_TEXTURE_2D);<br>
+       }<br>
+}<br>
+<br>
+void<br>
+fill_texture(GLuint name, GLenum target, const float *color,<br>
+            int width, int height, int depth)<br>
+{<br>
+       float *image;<br>
+       int i, size;<br>
+<br>
+       size = width * height * depth;<br>
+<br>
+       image = malloc(sizeof(float) * 3 * size);<br>
+       for (i = 0; i < size; i++)<br>
+               memcpy(&image[i*3], color, sizeof(float) * 3);<br>
+<br>
+       glBindTexture(target, name);<br>
+       glTexImage2D(target, 0, GL_RGB, width, height,<br>
+                    0, GL_RGB, GL_FLOAT, image);<br>
+       glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST);<br>
+       glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST);<br>
+<br>
+       free(image);<br>
+}<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       bool pass = true;<br>
+       struct image images[2];<br>
+<br>
+       if (renderbuffers >= 1)<br>
+               images[0].target = GL_RENDERBUFFER_EXT;<br>
+       else<br>
+               images[0].target = GL_TEXTURE_2D;<br>
+<br>
+       if (renderbuffers == 2)<br>
+               images[1].target = GL_RENDERBUFFER_EXT;<br>
+       else<br>
+               images[1].target = GL_TEXTURE_2D;<br>
+<br>
+       image_init(&images[0], images[0].target, GL_RGB);<br>
+       image_init(&images[1], images[1].target, GL_RGB);<br>
+<br>
+       image_fill(&images[0], green);<br>
+       image_fill(&images[1], red);<br>
+<br>
+       glCopyImageSubData(images[0].<u></u>name, images[0].target, 0, 0, 0, 0,<br>
+                          images[1].name, images[1].target, 0, 17, 11, 0,<br>
+                          32, 32, 1);<br>
+       pass &= piglit_check_gl_error(GL_NO_<u></u>ERROR);<br>
+<br>
+       /* We should now have a green square on red */<br>
+       glBindFramebufferEXT(GL_READ_<u></u>FRAMEBUFFER_EXT, images[1].fbo);<br>
+       pass &= piglit_probe_rect_rgb(17, 11, 32, 32, green);<br>
+       pass &= piglit_probe_rect_rgb(0, 0, 64, 11, red);<br>
+       pass &= piglit_probe_rect_rgb(0, 11, 17, 32, red);<br>
+       pass &= piglit_probe_rect_rgb(49, 11, 15, 32, red);<br>
+       pass &= piglit_probe_rect_rgb(0, 43, 64, 21, red);<br>
+<br>
+       image_fill(&images[0], blue);<br>
+       glBindFramebufferEXT(GL_READ_<u></u>FRAMEBUFFER_EXT, images[0].fbo);<br>
+       pass &= piglit_probe_rect_rgb(0, 0, 64, 64, blue);<br>
+<br>
+       glCopyImageSubData(images[1].<u></u>name, images[1].target, 0, 17, 11, 0,<br>
+                          images[0].name, images[0].target, 0, 0, 32, 0,<br>
+                          32, 32, 1);<br>
+       pass &= piglit_check_gl_error(GL_NO_<u></u>ERROR);<br>
+<br>
+       /* This should be a green square on blue (no red!) */<br>
+       glBindFramebufferEXT(GL_READ_<u></u>FRAMEBUFFER_EXT, images[0].fbo);<br>
+       pass &= piglit_probe_rect_rgb(0, 32, 32, 32, green);<br>
+       pass &= piglit_probe_rect_rgb(0, 0, 64, 32, blue);<br>
+       pass &= piglit_probe_rect_rgb(32, 32, 32, 32, blue);<br>
</blockquote>
<br></div></div>
In some piglit tests we use the pattern:<br>
<br>
   pass = test_something() && pass;<br>
<br>
to report multiple failures.  I'm not sure if you want to do that here though.<div class=""><br></div></blockquote><div><br></div><div>Yes, that should prevent short-circuiting.  That said, I haven't observed any short-circuiting of test functions.  Maybe a GCC thing?<br>
</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+<br>
+       if (!piglit_automatic) {<br>
+               glBindFramebufferEXT(GL_DRAW_<u></u>FRAMEBUFFER_EXT,<br>
+                                    piglit_winsys_fbo);<br>
+<br>
+               image_draw(&images[1], 0, 0);<br>
+               image_draw(&images[0], 64, 0);<br>
+<br>
+               piglit_present_results();<br>
+       }<br>
+<br>
+       image_destroy(&images[0]);<br>
+       image_destroy(&images[1]);<br>
+<br>
+       return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
<br>
</blockquote>
<br></div>
Looks good otherwise.<br>
Reviewed-by: Brian Paul <<a href="mailto:brianp@vmware.com" target="_blank">brianp@vmware.com</a>><br></blockquote><div><br></div><div>Thanks.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<br>
______________________________<u></u>_________________<br>
Piglit mailing list<br>
<a href="mailto:Piglit@lists.freedesktop.org" target="_blank">Piglit@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/piglit" target="_blank">http://lists.freedesktop.org/<u></u>mailman/listinfo/piglit</a><br>
</blockquote></div><br></div></div>