Skip to content
Snippets Groups Projects
Commit dae6b6a2 authored by Eric Smith's avatar Eric Smith Committed by Marge Bot
Browse files

panfrost: fix an incorrect stencil clear optimization


We track stencil clears and writes to optimize them. Unfortunately, the
code for doing this tracks the whole resource, not individual layers or
levels within the resource, which can result in incorrect output when
different levels or layers are accessed. Modified to optimize only the first
layer/level; this will handle the common case of a single stencil texture
while allowing arrays or mipmaps to still work (albeit slightly slower).

The original optimization was introduced in a2463ec2 ("panfrost:
Constant stencil buffer tracking") but the code has been reformatted
since then, so this change won't apply as-is that far back (although it's
fairly obvious how to apply it by hand).

Fixes: a2463ec2 ("panfrost: Constant stencil value tracking")
Signed-off-by: default avatarEric R. Smith <eric.smith@collabora.com>
Reviewed-by: default avatarBoris Brezillon <boris.brezillon@collabora.com>
Acked-by: default avatarErik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <mesa/mesa!28832>
parent e89123ec
No related branches found
No related tags found
Loading
......@@ -640,16 +640,19 @@ panfrost_batch_submit(struct panfrost_context *ctx,
struct pipe_surface *surf = batch->key.zsbuf;
struct panfrost_resource *z_rsrc = pan_resource(surf->texture);
/* Shared depth/stencil resources are not supported, and would
* break this optimisation. */
assert(!(z_rsrc->base.bind & PAN_BIND_SHARED_MASK));
if (batch->clear & PIPE_CLEAR_STENCIL) {
z_rsrc->stencil_value = batch->clear_stencil;
z_rsrc->constant_stencil = true;
} else if (z_rsrc->constant_stencil) {
batch->clear_stencil = z_rsrc->stencil_value;
batch->clear |= PIPE_CLEAR_STENCIL;
/* if there are multiple levels or layers, we optimize only the first */
if (surf->u.tex.level == 0 && surf->u.tex.first_layer == 0) {
/* Shared depth/stencil resources are not supported, and would
* break this optimisation. */
assert(!(z_rsrc->base.bind & PAN_BIND_SHARED_MASK));
if (batch->clear & PIPE_CLEAR_STENCIL) {
z_rsrc->stencil_value = batch->clear_stencil;
z_rsrc->constant_stencil = true;
} else if (z_rsrc->constant_stencil) {
batch->clear_stencil = z_rsrc->stencil_value;
batch->clear |= PIPE_CLEAR_STENCIL;
}
}
if (batch->draws & PIPE_CLEAR_STENCIL)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment