Mesa (master): gallium/util: Add helpers to determine if z/s is written
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Wed Jan 20 23:34:37 UTC 2021
Module: Mesa
Branch: master
Commit: 7277342b5e8a0a83045621ac77d2c54f9861353f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=7277342b5e8a0a83045621ac77d2c54f9861353f
Author: Rob Clark <robdclark at chromium.org>
Date: Wed Jan 20 10:27:55 2021 -0800
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 at chromium.org>
Reviewed-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8598>
---
src/gallium/auxiliary/util/u_inlines.h | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/gallium/auxiliary/util/u_inlines.h b/src/gallium/auxiliary/util/u_inlines.h
index e79e977a441..c5aadc7ca18 100644
--- a/src/gallium/auxiliary/util/u_inlines.h
+++ b/src/gallium/auxiliary/util/u_inlines.h
@@ -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)
{
More information about the mesa-commit
mailing list