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

2013-03-04 Thread Paul Berry
On 26 February 2013 12:39, Eric Anholt  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@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/piglit
>
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


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

2013-02-26 Thread Eric Anholt
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;
+}
+
 /**
  * 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@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit