panfrost: Always use a fragment shader when alpha test is enabled

Fixes incorrect rendering with OpenSCAD.

Fixes: 275277a2b4 ("panfrost: Implement alpha testing natively")
Reported-by: Urja Rannikko <urjaman@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11812>
This commit is contained in:
Icecream95 2021-07-10 00:31:02 +12:00 committed by Marge Bot
parent ecdb433254
commit efb0dd6de2
1 changed files with 10 additions and 4 deletions

View File

@ -284,13 +284,19 @@ static bool
panfrost_fs_required(
struct panfrost_shader_state *fs,
struct panfrost_blend_state *blend,
struct pipe_framebuffer_state *state)
struct pipe_framebuffer_state *state,
const struct panfrost_zsa_state *zsa)
{
/* If we generally have side effects. This inclues use of discard,
* which can affect the results of an occlusion query. */
if (fs->info.fs.sidefx)
return true;
/* Using an empty FS requires early-z to be enabled, but alpha test
* needs it disabled */
if ((enum mali_func) zsa->base.alpha_func != MALI_FUNC_ALWAYS)
return true;
/* If colour is written we need to execute */
for (unsigned i = 0; i < state->nr_cbufs; ++i) {
if (state->cbufs[i] && !blend->info[i].no_colour)
@ -518,7 +524,7 @@ panfrost_prepare_fs_state(struct panfrost_context *ctx,
bool msaa = rast->multisample;
pan_pack(rsd, RENDERER_STATE, cfg) {
if (pan_is_bifrost(dev) && panfrost_fs_required(fs, so, &ctx->pipe_framebuffer)) {
if (pan_is_bifrost(dev) && panfrost_fs_required(fs, so, &ctx->pipe_framebuffer, zsa)) {
/* Track if any colour buffer is reused across draws, either
* from reading it directly, or from failing to write it */
unsigned rt_mask = ctx->fb_rt_mask;
@ -532,7 +538,7 @@ panfrost_prepare_fs_state(struct panfrost_context *ctx,
} else if (!pan_is_bifrost(dev)) {
unsigned rt_count = ctx->pipe_framebuffer.nr_cbufs;
if (panfrost_fs_required(fs, ctx->blend, &ctx->pipe_framebuffer)) {
if (panfrost_fs_required(fs, ctx->blend, &ctx->pipe_framebuffer, zsa)) {
cfg.properties.midgard.force_early_z =
fs->info.fs.can_early_z && !alpha_to_coverage &&
((enum mali_func) zsa->base.alpha_func == MALI_FUNC_ALWAYS);
@ -637,7 +643,7 @@ panfrost_emit_frag_shader(struct panfrost_context *ctx,
}
/* Merge with CSO state and upload */
if (panfrost_fs_required(fs, ctx->blend, &ctx->pipe_framebuffer))
if (panfrost_fs_required(fs, ctx->blend, &ctx->pipe_framebuffer, zsa))
pan_merge(rsd, fs->partial_rsd, RENDERER_STATE);
else
pan_merge_empty_fs(&rsd, pan_is_bifrost(dev));