<div dir="ltr">On 5 February 2013 22:52, Kenneth Graunke <span dir="ltr"><<a href="mailto:kenneth@whitecape.org" target="_blank">kenneth@whitecape.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">

<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">This test fills the window with expected depth/stencil values, and uses<br>
CopyTexImage2D to copy those to a texture.  It then reads back the<br>
texture and verifies that both depth and stencil were successfully<br>
copied.<br>
<br>
This is particularly useful because on Sandybridge and later hardware,<br>
we use a separate stencil buffer, which means that GPU CopyTexImage<br>
paths can easily forget to copy stencil.<br>
<br>
The existing copyteximage test includes packed depth/stencil formats,<br>
but only validates the resulting depth values, not stencil.<br>
<br>
Cc: Paul Berry <<a href="mailto:stereotype441@gmail.com" target="_blank">stereotype441@gmail.com</a>><br></blockquote><div><br></div>This is definitely better than what we had before, but I would be more comfortable if we expanded the test to verify:<br>
<br></div><div class="gmail_quote">(a) that pixels aren't scrambled in some way by glCopyTexImage2D (since stencil buffers use W tiling, it wouldn't be hugely surprising for us to have a bug in this department)<br>
</div><div class="gmail_quote"><br>(b) that copying works from both FBOs and window system buffers (since these have different Y coordinate conventions, it wouldn't be surprising for us to have a bug causing us to flip the Y coordinate in one or the other case)<br>
</div><div class="gmail_quote"><br>(c) that glCopyTexImage3D() is properly respecting the x, y, width, and height arguments (currently the test just passes in 0 for x and y, and it doesn't try to read back the width and height of the texture to verify that they were set correctly)<br>
<br></div><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
 tests/all.tests                             |   1 +<br>
 tests/texturing/CMakeLists.gl.txt           |   1 +<br>
 tests/texturing/copyteximage-depthstencil.c | 109 ++++++++++++++++++++++++++++<br>
 3 files changed, 111 insertions(+)<br>
 create mode 100644 tests/texturing/copyteximage-depthstencil.c<br>
<br>
Sure enough, testing things catches bugs.<br>
<br>
diff --git a/tests/all.tests b/tests/all.tests<br>
index 2ffc6e1..6bc4d39 100644<br>
--- a/tests/all.tests<br>
+++ b/tests/all.tests<br>
@@ -1618,6 +1618,7 @@ add_fbo_formats_tests('spec/EXT_packed_depth_stencil', 'GL_EXT_packed_depth_sten<br>
 add_texwrap_format_tests(ext_packed_depth_stencil, 'GL_EXT_packed_depth_stencil')<br>
 ext_packed_depth_stencil['readpixels-24_8'] = PlainExecTest(['ext_packed_depth_stencil-readpixels-24_8', '-auto'])<br>
 add_plain_test(ext_packed_depth_stencil, 'fbo-blit-d24s8')<br>
+add_plain_test(ext_packed_depth_stencil, 'copyteximage-depthstencil')<br>
 # Note: the buffer sizes of 146, 292, 585, and 1024 hav been chosen to<br>
 # exercise all possible combinations of buffer alignments on i965.<br>
 for texture_size in (146, 292, 585, 1024):<br>
diff --git a/tests/texturing/CMakeLists.gl.txt b/tests/texturing/CMakeLists.gl.txt<br>
index c9e5d11..b78416b 100644<br>
--- a/tests/texturing/CMakeLists.gl.txt<br>
+++ b/tests/texturing/CMakeLists.gl.txt<br>
@@ -18,6 +18,7 @@ piglit_add_executable (copytexsubimage copytexsubimage.c)<br>
 piglit_add_executable (copyteximage copyteximage.c)<br>
 piglit_add_executable (copyteximage-border copyteximage-border.c)<br>
 piglit_add_executable (copyteximage-clipping copyteximage-clipping.c)<br>
+piglit_add_executable (copyteximage-depthstencil copyteximage-depthstencil.c)<br>
 piglit_add_executable (crossbar crossbar.c)<br>
 piglit_add_executable (cubemap cubemap.c)<br>
 piglit_add_executable (cubemap-shader cubemap-shader.c)<br>
diff --git a/tests/texturing/copyteximage-depthstencil.c b/tests/texturing/copyteximage-depthstencil.c<br>
new file mode 100644<br>
index 0000000..65a9558<br>
--- /dev/null<br>
+++ b/tests/texturing/copyteximage-depthstencil.c<br>
@@ -0,0 +1,109 @@<br>
+/*<br>
+ * Copyright © 2013 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>
+/**<br>
+ * @file copyteximage-depthstencil.c<br>
+ *<br>
+ * A basic test that makes sure glCopyTexImage actually copies both depth<br>
+ * and stencil data.<br>
+ */<br>
+<br>
+#include "piglit-util-gl-common.h"<br>
+<br>
+#define TEX_WIDTH 128<br>
+#define TEX_HEIGHT 4<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_BEGIN<br>
+<br>
+       config.supports_gl_compat_version = 10;<br>
+<br>
+       config.window_width = TEX_WIDTH;<br>
+       config.window_height = TEX_HEIGHT;<br>
+       config.window_visual = PIGLIT_GL_VISUAL_DOUBLE |<br>
+                              PIGLIT_GL_VISUAL_RGB |<br>
+                              PIGLIT_GL_VISUAL_DEPTH |<br>
+                              PIGLIT_GL_VISUAL_STENCIL;<br>
+<br>
+PIGLIT_GL_TEST_CONFIG_END<br>
+<br>
+enum piglit_result<br>
+piglit_display(void)<br>
+{<br>
+       return PIGLIT_FAIL;<br>
+}<br>
+<br>
+void piglit_init(int argc, char **argv)<br>
+{<br>
+       GLuint tex;<br>
+       GLfloat depth[TEX_WIDTH * TEX_HEIGHT];<br>
+       GLuint ds[TEX_WIDTH * TEX_HEIGHT];<br>
+       int i;<br>
+<br>
+       const float expected_depth = 0.7;<br>
+       const int expected_stencil = 0x42;<br>
+<br>
+       bool pass = true;<br>
+<br>
+       piglit_require_extension("GL_EXT_packed_depth_stencil");<br>
+<br>
+       /* Fill the window with expected depth/stencil values */<br>
+       glClearDepth(expected_depth);<br>
+       glClearStencil(expected_stencil);<br>
+       glClear(GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);<br>
+<br>
+       /* Copy the data to the texture */<br>
+       glGenTextures(1, &tex);<br>
+       glBindTexture(GL_TEXTURE_2D, tex);<br>
+       glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8,<br>
+                        0, 0, TEX_WIDTH, TEX_HEIGHT, 0);<br>
+       piglit_check_gl_error(GL_NO_ERROR);<br>
+<br>
+       /* Read back the texture */<br>
+       glGetTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, GL_FLOAT, depth);<br>
+       piglit_check_gl_error(GL_NO_ERROR);<br>
+<br>
+       glGetTexImage(GL_TEXTURE_2D, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, ds);<br>
+       piglit_check_gl_error(GL_NO_ERROR);<br>
+<br>
+       /* Check for expected values */<br>
+       for (i = 0; i < TEX_WIDTH * TEX_HEIGHT; ++i) {<br>
+               int x = i % TEX_WIDTH;<br>
+               int y = i / TEX_WIDTH;<br>
+<br>
+               unsigned actual_stencil = ds[i] >> 24;<br>
+               float actual_depth = depth[i];<br>
+<br>
+               if (actual_depth != expected_depth) {<br>
+                       printf("Depth at (%d, %d) = %.2f, expected %.2f\n",<br>
+                              x, y, actual_depth, expected_depth);<br>
+                       pass = false;<br>
+               }<br>
+               if (actual_stencil != expected_stencil) {<br>
+                       printf("Stencil at (%d, %d) = 0x%x, expected 0x%x\n",<br>
+                              x, y, actual_stencil, expected_stencil);<br>
+                       pass = false;<br>
+               }<br>
+       }<br>
+<br>
+       piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);<br>
+}<br>
<span><font color="#888888">--<br>
1.8.1.2<br>
<br>
</font></span></blockquote></div><br></div></div>