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>
This commit is contained in:

committed by
Marge Bot

parent
ff44f813fb
commit
275277a2b4
@@ -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_mask_back = zsa->stencil_mask_back;
|
||||||
state->stencil_mask_misc.stencil_enable = zsa->base.stencil[0].enabled;
|
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_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_1 = rast->offset_tri;
|
||||||
state->stencil_mask_misc.depth_range_2 = rast->offset_tri;
|
state->stencil_mask_misc.depth_range_2 = rast->offset_tri;
|
||||||
state->stencil_mask_misc.single_sampled_lines = !rast->multisample;
|
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_back = zsa->stencil_back;
|
||||||
state->stencil_front.reference_value = ctx->stencil_ref.ref_value[0];
|
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];
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -1240,8 +1240,9 @@ panfrost_create_depth_stencil_state(struct pipe_context *pipe,
|
|||||||
so->stencil_mask_back = so->stencil_mask_front;
|
so->stencil_mask_back = so->stencil_mask_front;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Alpha lowered by frontend */
|
so->alpha_func = zsa->alpha_enabled ?
|
||||||
assert(!zsa->alpha_enabled);
|
panfrost_translate_compare_func(zsa->alpha_func) :
|
||||||
|
MALI_FUNC_ALWAYS;
|
||||||
|
|
||||||
/* TODO: Bounds test should be easy */
|
/* TODO: Bounds test should be easy */
|
||||||
assert(!zsa->depth_bounds_test);
|
assert(!zsa->depth_bounds_test);
|
||||||
|
@@ -282,6 +282,7 @@ struct panfrost_vertex_state {
|
|||||||
|
|
||||||
struct panfrost_zsa_state {
|
struct panfrost_zsa_state {
|
||||||
struct pipe_depth_stencil_alpha_state base;
|
struct pipe_depth_stencil_alpha_state base;
|
||||||
|
enum mali_func alpha_func;
|
||||||
|
|
||||||
/* Precomputed stencil state */
|
/* Precomputed stencil state */
|
||||||
struct MALI_STENCIL stencil_front;
|
struct MALI_STENCIL stencil_front;
|
||||||
|
@@ -267,7 +267,10 @@ panfrost_get_param(struct pipe_screen *screen, enum pipe_cap param)
|
|||||||
case PIPE_CAP_MAX_VARYINGS:
|
case PIPE_CAP_MAX_VARYINGS:
|
||||||
return 16;
|
return 16;
|
||||||
|
|
||||||
|
/* Removed in v6 (Bifrost) */
|
||||||
case PIPE_CAP_ALPHA_TEST:
|
case PIPE_CAP_ALPHA_TEST:
|
||||||
|
return dev->arch <= 5;
|
||||||
|
|
||||||
case PIPE_CAP_FLATSHADE:
|
case PIPE_CAP_FLATSHADE:
|
||||||
case PIPE_CAP_TWO_SIDED_COLOR:
|
case PIPE_CAP_TWO_SIDED_COLOR:
|
||||||
case PIPE_CAP_CLIP_PLANES:
|
case PIPE_CAP_CLIP_PLANES:
|
||||||
|
Reference in New Issue
Block a user