gallium/util: Add helpers to determine if z/s is written

For drivers that must control various 'early-z'-like state, it is easy
enough to get this wrong.  So add helpers so we don't have to duplicate
the logic in each driver.

Signed-off-by: Rob Clark <robdclark@chromium.org>
Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8598>
This commit is contained in:
Rob Clark 2021-01-20 10:27:55 -08:00 committed by Marge Bot
parent bc0508ad38
commit 7277342b5e
1 changed files with 20 additions and 0 deletions

View File

@ -763,6 +763,26 @@ util_logicop_reads_dest(enum pipe_logicop op)
unreachable("bad logicop");
}
static inline bool
util_writes_stencil(const struct pipe_stencil_state *s)
{
return s->enabled && s->writemask &&
((s->fail_op != PIPE_STENCIL_OP_KEEP) ||
(s->zpass_op != PIPE_STENCIL_OP_KEEP) ||
(s->zfail_op != PIPE_STENCIL_OP_KEEP));
}
static inline bool
util_writes_depth_stencil(const struct pipe_depth_stencil_alpha_state *zsa)
{
if (zsa->depth_enabled && zsa->depth_writemask &&
(zsa->depth_func != PIPE_FUNC_NEVER))
return true;
return util_writes_stencil(&zsa->stencil[0]) ||
util_writes_stencil(&zsa->stencil[1]);
}
static inline struct pipe_context *
pipe_create_multimedia_context(struct pipe_screen *screen)
{