panfrost: Fix dual-source blending

If dual blending is enabled, only 1 output is supported. Multiple
outputs confuse the write combining pass in this case, leading to
incorrect output and/or an assert failure in emit_fragment_store.

The fix is straightforward, just skip the speculative emitting of
multiple outputs in the case where dual source blending is enabled.

This also adds an extra sanity check in `pan_nir_lower_zs_store` to
check for only one blend store being present.

Fixes: c65a9be421 ("panfrost: Preprocess shaders at CSO create time")
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/9487
Co-Authored-By: Eric R. Smith <eric.smith@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26474>
(cherry picked from commit 49c1b404e5)
This commit is contained in:
Christian Duerr
2023-12-03 04:45:44 +01:00
committed by Eric Engestrom
parent 1bcb089aa7
commit 781ea0997b
3 changed files with 5 additions and 2 deletions

View File

@@ -594,7 +594,7 @@
"description": "panfrost: Fix dual-source blending",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "c65a9be421cd4a338939e29e9dca1d8f81f165ac",
"notes": null

View File

@@ -369,7 +369,8 @@ panfrost_create_shader_state(struct pipe_context *pctx,
if (nir->info.stage == MESA_SHADER_FRAGMENT &&
nir->info.outputs_written & BITFIELD_BIT(FRAG_RESULT_COLOR)) {
NIR_PASS_V(nir, nir_lower_fragcolor, 8);
NIR_PASS_V(nir, nir_lower_fragcolor,
nir->info.fs.color_is_dual_source ? 1 : 8);
so->fragcolor_lowered = true;
}

View File

@@ -106,6 +106,8 @@ pan_nir_lower_zs_store(nir_shader *nir)
stores[1] = intr;
writeout |= PAN_WRITEOUT_S;
} else if (sem.dual_source_blend_index) {
assert(!stores[2]); /* there should be only 1 source for dual
blending */
stores[2] = intr;
writeout |= PAN_WRITEOUT_2;
}