<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">
This will let the presentation of stencil work like presentation of<br>
depth.<br>
---<br>
 tests/texturing/depthstencil-render-miplevels.cpp |   13 +++++++++++--<br>
 1 file changed, 11 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/tests/texturing/depthstencil-render-miplevels.cpp b/tests/texturing/depthstencil-render-miplevels.cpp<br>
index 4fcc95a..b41fea8 100644<br>
--- a/tests/texturing/depthstencil-render-miplevels.cpp<br>
+++ b/tests/texturing/depthstencil-render-miplevels.cpp<br>
@@ -227,6 +227,14 @@ set_up_framebuffer_for_miplevel(int level)<br>
        }<br>
 }<br>
<br>
+uint8_t<br>
+stencil_for_level(int level)<br>
+{<br>
+       int step = 254 / max_miplevel;<br>
+<br>
+       return 1 + step * level;<br>
+}<br>
+<br></blockquote><div><br></div><div>This doesn't yield results consistent with the depth values.  I'd recommend doing this instead:<br><br>uint8_t<br>stencil_for_level(int level)<br>{<br>    float float_value = float(level + 1) / (max_miplevel + 1);<br>
    return (uint8_t) round(float_value * 255.0);<br>}<br><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>
  * Using glClear, set the contents of the depth and stencil buffers<br>
  * (if present) to a value that is unique to this miplevel.<br>
@@ -242,7 +250,7 @@ populate_miplevel(int level)<br>
                clear_mask |= GL_DEPTH_BUFFER_BIT;<br>
        }<br>
        if (attach_stencil) {<br>
-               glClearStencil(level + 1);<br>
+               glClearStencil(stencil_for_level(level));<br>
                clear_mask |= GL_STENCIL_BUFFER_BIT;<br>
        }<br>
<br>
@@ -268,7 +276,8 @@ test_miplevel(int level)<br>
<br>
        if (attach_stencil) {<br>
                printf("Probing miplevel %d stencil\n", level);<br>
-               pass = piglit_probe_rect_stencil(0, 0, dim, dim, level + 1)<br>
+               pass = piglit_probe_rect_stencil(0, 0, dim, dim,<br>
+                                                stencil_for_level(level))<br>
                        && pass;<br>
        }<br>
<span class=""><font color="#888888"><br>
--<br>
1.7.10.4<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></div></div>