[Mesa-dev] [PATCH] i965/msaa: Set KILL_ENABLE when GL_ALPHA_TO_COVERAGE enabled.

Anuj Phogat anuj.phogat at gmail.com
Mon Jun 25 18:17:20 PDT 2012


On Mon, Jun 25, 2012 at 5:39 PM, Paul Berry <stereotype441 at gmail.com> wrote:
> i965 hardware needs to be informed of situations in which it's
> possible for pixels (or samples) to be discarded for reasons other
> than depth/stencil testing (e.g. due to an explicit "discard" in the
> fragment shader).  One of these situations is when
> GL_ALPHA_TO_COVERAGE is enabled, since that can cause samples to be
> discarded by the color calculator when the pixel's alpha value is less
> than 1.0.
>
> Without this patch, GL_ALPHA_TO_COVERAGE does not take effect on depth
> buffers.
> ---
>  src/mesa/drivers/dri/i965/gen6_wm_state.c |    5 +++--
>  src/mesa/drivers/dri/i965/gen7_wm_state.c |    5 +++--
>  2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/gen6_wm_state.c b/src/mesa/drivers/dri/i965/gen6_wm_state.c
> index 662435e..fa83ece 100644
> --- a/src/mesa/drivers/dri/i965/gen6_wm_state.c
> +++ b/src/mesa/drivers/dri/i965/gen6_wm_state.c
> @@ -186,8 +186,9 @@ upload_wm_state(struct brw_context *brw)
>    dw6 |= brw->wm.prog_data->barycentric_interp_modes <<
>       GEN6_WM_BARYCENTRIC_INTERPOLATION_MODE_SHIFT;
>
> -   /* _NEW_COLOR */
> -   if (fp->program.UsesKill || ctx->Color.AlphaEnabled)
> +   /* _NEW_COLOR, _NEW_MULTISAMPLE */
> +   if (fp->program.UsesKill || ctx->Color.AlphaEnabled ||
> +       ctx->Multisample.SampleAlphaToCoverage)
>       dw5 |= GEN6_WM_KILL_ENABLE;
>
>    if (brw_color_buffer_write_enabled(brw) ||
> diff --git a/src/mesa/drivers/dri/i965/gen7_wm_state.c b/src/mesa/drivers/dri/i965/gen7_wm_state.c
> index 45c8e46..8e4417e 100644
> --- a/src/mesa/drivers/dri/i965/gen7_wm_state.c
> +++ b/src/mesa/drivers/dri/i965/gen7_wm_state.c
> @@ -70,8 +70,9 @@ upload_wm_state(struct brw_context *brw)
>    dw1 |= brw->wm.prog_data->barycentric_interp_modes <<
>       GEN7_WM_BARYCENTRIC_INTERPOLATION_MODE_SHIFT;
>
> -   /* _NEW_COLOR */
> -   if (fp->program.UsesKill || ctx->Color.AlphaEnabled)
> +   /* _NEW_COLOR, _NEW_MULTISAMPLE */
> +   if (fp->program.UsesKill || ctx->Color.AlphaEnabled ||
> +       ctx->Multisample.SampleAlphaToCoverage)
>       dw1 |= GEN7_WM_KILL_ENABLE;
>
>    /* _NEW_BUFFERS */
> --
> 1.7.7.6
>

This patch makes piglit sample-alpha-to-coverage  test pass for depth buffer.
 I'll soon send out a patch to enable depth buffer testing in existing
piglit test case.

Reviewed-by: Anuj Phogat <anuj.phogat at gmail.com>


More information about the mesa-dev mailing list