[Mesa-dev] [PATCH 0/8] Clamp stencil reference value at use, not at specification time.

Kenneth Graunke kenneth at whitecape.org
Mon May 13 10:25:29 PDT 2013


On 05/13/2013 04:10 AM, Chris Forbes wrote:
> Replaces: "[PATCH] mesa: Fix meta smashing stencil reference value on restore"
>
> This series changes the way stencil reference values are clamped. Previously,
> the values would be clamped according to the bit depth of the stencil buffer
> bound _when the the value was specified_. This looked correct in most cases, but fell apart
> in some cases where the stencil buffer validated against is not the same as the buffer that
> would be rendered into.
>
>
> A simple example is this sequence, which would produce a reference value of zero,
> even though the user probably meant otherwise:
>
> 1. BindFramebuffer( .. fbo with NO stencil )
> 2. StencilFuncSeparate( .. 0xff .. )
> 3. BindFramebuffer( .. fbo with stencil )
>
>
> A more realistic case involves a meta op restoring the stencil state, which is done by calling
> the StencilFuncSeparate() API just the same as the user:
>
> 1. BindFramebuffer( .. fbo with stencil )
> 2. StencilFuncSeparate( .. 0xff .. )
> 3. BindFramebuffer( .. fbo with NO stencil .. )
> 4. <some meta op>
> 5. BindFramebuffer( .. fbo with stencil )
>
> In this case, the stencil reference value would be revalidated against zero stencil
> bits at (4) and so smashed to zero. This sequence is from Portal.
>
>
> This series moves the clamping to the point of use, which is consistent with the 3.2 spec,
> and the behavior of NVIDIA's driver.
>
> Fixes broken rendering in Portal.
>
> Thanks to Ken for pointing out my misinterpretation of the spec in my original patch.
>
> -- Chris

For the series:
NOTE: This is a candidate for stable branches.
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>

Thanks so much for fixing this, Chris!


More information about the mesa-dev mailing list