agx: Move nir_lower_fragcolor out of agx_preprocess_nir

Do not apply "nir_lower_fragcolor" in the common code.

This fix a crash on agxv side when a frag shader have SSBO writes.

This is caused by "nir_lower_frag_color" assuming that every
"store_deref" will have a variable backing the
output.

Signed-off-by: Mary <mary@mary.zone>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24635>
This commit is contained in:
Mary 2023-08-11 12:18:47 +02:00 committed by Marge Bot
parent 3704caca0b
commit 0f4e3a03fd
2 changed files with 8 additions and 6 deletions

View file

@ -2581,12 +2581,6 @@ agx_preprocess_nir(nir_shader *nir, bool support_lod_bias, bool allow_mediump,
if (nir->info.stage == MESA_SHADER_VERTEX) {
NIR_PASS_V(nir, nir_lower_point_size, 1.0, 0.0);
} else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
/* Lower to maximum colour buffers, the excess stores will get cleaned up
* by tilebuffer lowering so they won't become real shader code. However,
* that depends on the shader key which we don't have at this point.
*/
NIR_PASS_V(nir, nir_lower_fragcolor, 8);
}
/* Lower large arrays to scratch and small arrays to csel */

View file

@ -1721,6 +1721,14 @@ agx_shader_initialize(struct agx_device *dev, struct agx_uncompiled_shader *so,
*/
NIR_PASS_V(nir, agx_nir_lower_bindings, &so->internal_bindless);
if (nir->info.stage == MESA_SHADER_FRAGMENT) {
/* Lower to maximum colour buffers, the excess stores will get cleaned up
* by tilebuffer lowering so they won't become real shader code. However,
* that depends on the shader key which we don't have at this point.
*/
NIR_PASS_V(nir, nir_lower_fragcolor, 8);
}
bool allow_mediump = !(dev->debug & AGX_DBG_NO16);
agx_preprocess_nir(nir, true, allow_mediump, &so->info);