diff options
author | Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> | 2021-01-12 11:44:43 -0500 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-01-13 15:17:32 +0000 |
commit | 275277a2b48ce38fba1d5203941e987fdc856e92 (patch) | |
tree | 6ab1d759c858e4b4c76977fcb549151e2c466e0b | |
parent | ff44f813fbe9ce703d77b1881a302ef25c21f96b (diff) |
panfrost: Implement alpha testing natively
On Midgard, we still have to lower on v6+. Passes Piglit
./fbo-mrt-alphatest (saving a cycle in the fragment shader to
compare/discard).
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8447>
-rw-r--r-- | src/gallium/drivers/panfrost/pan_cmdstream.c | 6 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.c | 5 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.h | 1 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_screen.c | 3 |
4 files changed, 12 insertions, 3 deletions
diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index a4b90332171..9922c76e29d 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -542,7 +542,7 @@ panfrost_prepare_fs_state(struct panfrost_context *ctx, state->stencil_mask_misc.stencil_mask_back = zsa->stencil_mask_back; state->stencil_mask_misc.stencil_enable = zsa->base.stencil[0].enabled; state->stencil_mask_misc.alpha_to_coverage = alpha_to_coverage; - state->stencil_mask_misc.alpha_test_compare_function = MALI_FUNC_ALWAYS; + state->stencil_mask_misc.alpha_test_compare_function = zsa->alpha_func; state->stencil_mask_misc.depth_range_1 = rast->offset_tri; state->stencil_mask_misc.depth_range_2 = rast->offset_tri; state->stencil_mask_misc.single_sampled_lines = !rast->multisample; @@ -554,6 +554,10 @@ panfrost_prepare_fs_state(struct panfrost_context *ctx, state->stencil_back = zsa->stencil_back; state->stencil_front.reference_value = ctx->stencil_ref.ref_value[0]; state->stencil_back.reference_value = ctx->stencil_ref.ref_value[back_enab ? 1 : 0]; + + /* v6+ fits register preload here, no alpha testing */ + if (dev->arch <= 5) + state->alpha_reference = zsa->base.alpha_ref_value; } diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 03988f05d3f..54a279ec35d 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -1240,8 +1240,9 @@ panfrost_create_depth_stencil_state(struct pipe_context *pipe, so->stencil_mask_back = so->stencil_mask_front; } - /* Alpha lowered by frontend */ - assert(!zsa->alpha_enabled); + so->alpha_func = zsa->alpha_enabled ? + panfrost_translate_compare_func(zsa->alpha_func) : + MALI_FUNC_ALWAYS; /* TODO: Bounds test should be easy */ assert(!zsa->depth_bounds_test); diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index 7d2f26a2809..a65442a88bb 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -282,6 +282,7 @@ struct panfrost_vertex_state { struct panfrost_zsa_state { struct pipe_depth_stencil_alpha_state base; + enum mali_func alpha_func; /* Precomputed stencil state */ struct MALI_STENCIL stencil_front; diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index 4aea02e3566..e94534abb64 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -267,7 +267,10 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_MAX_VARYINGS: return 16; + /* Removed in v6 (Bifrost) */ case PIPE_CAP_ALPHA_TEST: + return dev->arch <= 5; + case PIPE_CAP_FLATSHADE: case PIPE_CAP_TWO_SIDED_COLOR: case PIPE_CAP_CLIP_PLANES: |