<div dir="ltr">On 26 February 2013 12:39, Eric Anholt <span dir="ltr"><<a href="mailto:eric@anholt.net" target="_blank">eric@anholt.net</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">

I tried to make the presentation be the data that was originally<br>
probed -- there's a second readpixels that's unfortunately, but we do<br>
use separate textures so that any workaround relayouts of the probed<br>
textures don't get tweaked in the process of displaying.<br></blockquote><div><br></div><div>I'm having trouble parsing this sentence.  Can you explain further?<br></div><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/texturing/depthstencil-render-miplevels.cpp |  105 ++++++++++++++++++++-<br>
 1 file changed, 102 insertions(+), 3 deletions(-)<br>
<br>
diff --git a/tests/texturing/depthstencil-render-miplevels.cpp b/tests/texturing/depthstencil-render-miplevels.cpp<br>
index b41fea8..2ffe07d 100644<br>
--- a/tests/texturing/depthstencil-render-miplevels.cpp<br>
+++ b/tests/texturing/depthstencil-render-miplevels.cpp<br>
@@ -90,8 +90,8 @@ PIGLIT_GL_TEST_CONFIG_BEGIN<br>
<br>
        config.supports_gl_compat_version = 10;<br>
<br>
-       config.window_width = 16;<br>
-       config.window_height = 16;<br>
+       config.window_width = 512;<br>
+       config.window_height = 512;<br>
        config.window_visual = PIGLIT_GL_VISUAL_RGBA;<br>
<br>
 PIGLIT_GL_TEST_CONFIG_END<br>
@@ -109,7 +109,8 @@ bool attach_stencil_first = false;<br>
 GLenum depth_format;<br>
 int miplevel0_size;<br>
 int max_miplevel;<br>
-<br>
+float **depth_miplevel_data;<br>
+uint8_t **stencil_miplevel_data;<br>
<br>
 /**<br>
  * Check if the given depth/stencil/rgba texture internal format is supported.<br>
@@ -260,6 +261,9 @@ populate_miplevel(int level)<br>
 /**<br>
  * Test that every pixel in the depth and stencil buffers (if present)<br>
  * is equal to the value set by populate_miplevel.<br>
+ *<br>
+ * If we're going to later render our results to the screen for<br>
+ * debugging, then save off a copy of the data we read now.<br>
  */<br>
 bool<br>
 test_miplevel(int level)<br>
@@ -272,6 +276,14 @@ test_miplevel(int level)<br>
                printf("Probing miplevel %d depth\n", level);<br>
                pass = piglit_probe_rect_depth(0, 0, dim, dim, float_value)<br>
                        && pass;<br>
+<br>
+               if (!piglit_automatic) {<br>
+                       depth_miplevel_data[level] =<br>
+                               (float *)malloc(4 * dim * dim);<br>
+                       glReadPixels(0, 0, dim, dim,<br>
+                                    GL_DEPTH_COMPONENT, GL_FLOAT,<br>
+                                    depth_miplevel_data[level]);<br>
+               }<br>
        }<br>
<br>
        if (attach_stencil) {<br>
@@ -279,6 +291,14 @@ test_miplevel(int level)<br>
                pass = piglit_probe_rect_stencil(0, 0, dim, dim,<br>
                                                 stencil_for_level(level))<br>
                        && pass;<br>
+<br>
+               if (!piglit_automatic) {<br>
+                       stencil_miplevel_data[level] =<br>
+                               (uint8_t *)malloc(dim * dim);<br>
+                       glReadPixels(0, 0, dim, dim,<br>
+                                    GL_STENCIL_INDEX, GL_UNSIGNED_BYTE,<br>
+                                    stencil_miplevel_data[level]);<br>
+               }<br>
        }<br>
<br>
        return pass;<br>
@@ -332,6 +352,9 @@ piglit_init(int argc, char **argv)<br>
                while ((miplevel0_size >> (max_miplevel + 1)) > 0)<br>
                        ++max_miplevel;<br>
        }<br>
+       depth_miplevel_data = (float **)calloc(max_miplevel, sizeof(float *));<br>
+       stencil_miplevel_data = (uint8_t **)calloc(max_miplevel,<br>
+                                                  sizeof(uint8_t *));<br>
<br>
        /* argv[2]: buffer combination */<br>
        if (strcmp(argv[2], "s=z24_s8") == 0) {<br>
@@ -426,6 +449,79 @@ piglit_init(int argc, char **argv)<br>
        }<br>
 }<br>
<br>
+static void<br>
+render_tex_to_screen(GLuint tex, int x, int y)<br>
+{<br>
+       glBindTexture(GL_TEXTURE_2D, tex);<br>
+       glEnable(GL_TEXTURE_2D);<br>
+<br>
+       for (int level = 0; level <= max_miplevel; ++level) {<br>
+               int dim = miplevel0_size >> level; <br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+               piglit_draw_rect_tex(x, y, dim, dim,<br>
+                                    0, 0, 1, 1);<br>
+<br>
+               y += dim + 1;<br>
+       }<br>
+}<br>
+<br>
+/**<br>
+ * Presents the results of the rendering on the screen.<br>
+ */<br>
+static void<br>
+render_results_to_screen()<br>
+{<br>
+       GLuint tex;<br>
+<br>
+       printf("\n");<br>
+       printf("Depth is on the left, stencil is on the right.\n");<br>
+       printf("Colors should proceed from nearly-black to nearly-red.\n");<br>
+<br>
+       piglit_ortho_projection(piglit_width, piglit_height, false);<br></blockquote><div><br></div><div>This function draws an image whose width and height are 2*miplevel0_size.  Since the window size is 512x512, that means that the whole image won't appear unless miplevel0_size is 256 or less (I believe this explains why Chad didn't see the image he expected when running "depthstencil-render-miplevels 1024 d=z24").<br>

<br></div><div>I'd be ok with a quick and dirty fix to this--for example, if you changed this to do piglit_ortho_projection(2*miplevel0_size, 2*miplevel0_size, false) in the case where miplevel0_size > 256, then the whole image would appear in the window, but scaled down.  It's hacky, but I think it would be good enough for what you're trying to achieve here.<br>

</div><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>
+       glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);<br>
+       glClearColor(0.5, 0.5, 0.5, 0.0);<br>
+       glClear(GL_COLOR_BUFFER_BIT);<br>
+<br>
+       glGenTextures(1, &tex);<br>
+       glBindTexture(GL_TEXTURE_2D, tex);<br>
+<br>
+       if (attach_depth) {<br>
+               for (int level = 0; level <= max_miplevel; ++level) {<br>
+                       int dim = miplevel0_size >> level;<br>
+<br>
+                       glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA,<br>
+                                    dim, dim,<br>
+                                    0,<br>
+                                    GL_RED, GL_FLOAT,<br>
+                                    depth_miplevel_data[level]);<br>
+                       if (!piglit_check_gl_error(GL_NO_ERROR))<br>
+                               piglit_report_result(PIGLIT_FAIL);<br>
+               }<br>
+<br>
+               render_tex_to_screen(tex, 0, 1);<br></blockquote><div><br></div><div>Any particular reason the y coordinate is 1 rather than 0?<br></div><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>
+<br>
+<br>
+       if (attach_stencil) {<br>
+               for (int level = 0; level <= max_miplevel; ++level) {<br>
+                       int dim = miplevel0_size >> level;<br>
+<br>
+                       glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA,<br>
+                                    dim, dim,<br>
+                                    0,<br>
+                                    GL_RED, GL_UNSIGNED_BYTE,<br>
+                                    stencil_miplevel_data[level]);<br>
+                       if (!piglit_check_gl_error(GL_NO_ERROR))<br>
+                               piglit_report_result(PIGLIT_FAIL);<br>
+               }<br>
+<br>
+               render_tex_to_screen(tex, miplevel0_size + 10, 1);<br></blockquote><div><br></div><div>Same question about the y coordinate here.<br></div><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>
+<br>
+       piglit_present_results();<br>
+}<br>
+<br>
 extern "C" enum piglit_result<br>
 piglit_display()<br>
 {<br>
@@ -467,6 +563,9 @@ piglit_display()<br>
                pass = test_miplevel(level) && pass;<br>
        }<br>
<br>
+       if (!piglit_automatic)<br>
+               render_results_to_screen();<br>
+<br>
        return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
 }<br>
<span><font color="#888888"><br>
--<br>
1.7.10.4<br>
<br>
_______________________________________________<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/mailman/listinfo/piglit</a><br>
</font></span></blockquote></div><br></div></div>