[Mesa-dev] [PATCH] st/mesa: Only enable depth writes if the function isn't EQUAL.

Marek Olšák maraeo at gmail.com
Thu Jul 5 18:24:22 UTC 2018


Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Thu, Jul 5, 2018 at 6:00 AM, Kenneth Graunke <kenneth at whitecape.org> wrote:
> If the depth function is EQUAL, then we'll only write the depth value
> when it already matches what's in the buffer, which is pointless.
> Skipping these writes can save bandwidth.
>
> The state tracker can easily take care of this, so all drivers benefit.
> ---
>  src/mesa/state_tracker/st_atom_depth.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> Not well tested, sorry.
>
> diff --git a/src/mesa/state_tracker/st_atom_depth.c b/src/mesa/state_tracker/st_atom_depth.c
> index 6ddb8f525cf..9e12361f881 100644
> --- a/src/mesa/state_tracker/st_atom_depth.c
> +++ b/src/mesa/state_tracker/st_atom_depth.c
> @@ -107,8 +107,9 @@ st_update_depth_stencil_alpha(struct st_context *st)
>     if (ctx->DrawBuffer->Visual.depthBits > 0) {
>        if (ctx->Depth.Test) {
>           dsa->depth.enabled = 1;
> -         dsa->depth.writemask = ctx->Depth.Mask;
>           dsa->depth.func = st_compare_func_to_pipe(ctx->Depth.Func);
> +         if (dsa->depth.func != PIPE_FUNC_EQUAL)
> +            dsa->depth.writemask = ctx->Depth.Mask;
>        }
>        if (ctx->Depth.BoundsTest) {
>           dsa->depth.bounds_test = 1;
> --
> 2.18.0
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list