[Piglit] [PATCH 2/3] depthstencil-render-miplevels: Make the stencil value scale like depth.

Paul Berry stereotype441 at gmail.com
Mon Mar 4 10:04:08 PST 2013


On 26 February 2013 12:39, Eric Anholt <eric at anholt.net> wrote:

> This will let the presentation of stencil work like presentation of
> depth.
> ---
>  tests/texturing/depthstencil-render-miplevels.cpp |   13 +++++++++++--
>  1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/tests/texturing/depthstencil-render-miplevels.cpp
> b/tests/texturing/depthstencil-render-miplevels.cpp
> index 4fcc95a..b41fea8 100644
> --- a/tests/texturing/depthstencil-render-miplevels.cpp
> +++ b/tests/texturing/depthstencil-render-miplevels.cpp
> @@ -227,6 +227,14 @@ set_up_framebuffer_for_miplevel(int level)
>         }
>  }
>
> +uint8_t
> +stencil_for_level(int level)
> +{
> +       int step = 254 / max_miplevel;
> +
> +       return 1 + step * level;
> +}
> +
>

This doesn't yield results consistent with the depth values.  I'd recommend
doing this instead:

uint8_t
stencil_for_level(int level)
{
    float float_value = float(level + 1) / (max_miplevel + 1);
    return (uint8_t) round(float_value * 255.0);
}



>  /**
>   * Using glClear, set the contents of the depth and stencil buffers
>   * (if present) to a value that is unique to this miplevel.
> @@ -242,7 +250,7 @@ populate_miplevel(int level)
>                 clear_mask |= GL_DEPTH_BUFFER_BIT;
>         }
>         if (attach_stencil) {
> -               glClearStencil(level + 1);
> +               glClearStencil(stencil_for_level(level));
>                 clear_mask |= GL_STENCIL_BUFFER_BIT;
>         }
>
> @@ -268,7 +276,8 @@ test_miplevel(int level)
>
>         if (attach_stencil) {
>                 printf("Probing miplevel %d stencil\n", level);
> -               pass = piglit_probe_rect_stencil(0, 0, dim, dim, level + 1)
> +               pass = piglit_probe_rect_stencil(0, 0, dim, dim,
> +                                                stencil_for_level(level))
>                         && pass;
>         }
>
> --
> 1.7.10.4
>
> _______________________________________________
> Piglit mailing list
> Piglit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20130304/a9e2d391/attachment.html>


More information about the Piglit mailing list