mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 18:08:40 +02:00
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 ina2463ec271("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:a2463ec271("panfrost: Constant stencil value tracking") Signed-off-by: Eric R. Smith <eric.smith@collabora.com> Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com> Acked-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/28832> (cherry picked from commitdae6b6a23d)
This commit is contained in:
parent
5345aceffa
commit
e8816cf5ae
2 changed files with 13 additions and 10 deletions
|
|
@ -384,7 +384,7 @@
|
|||
"description": "panfrost: fix an incorrect stencil clear optimization",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "a2463ec271ff4fe4513ce07b3881625add32ccdc",
|
||||
"notes": null
|
||||
|
|
|
|||
|
|
@ -635,16 +635,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 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->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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue