asahi: Run nir_lower_fragcolor during preprocessing

This pass needs to run early (because it depends on early I/O), but it doesn't
actually need the shader key. Why not? If we overestimate the number of render
targets, extra store_output intrinsics will be generated, but they will be
deleted by AGX tilebuffer lowering later.

Note we'll probably want something smarter than this for fragment epilogues in
the future to avoid piles of unnecessary moves.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21065>
This commit is contained in:
Alyssa Rosenzweig
2022-11-28 22:37:31 -05:00
committed by Marge Bot
parent 071ac59960
commit 6908a0dece
2 changed files with 8 additions and 3 deletions
+8 -1
View File
@@ -1882,8 +1882,15 @@ agx_preprocess_nir(nir_shader *nir)
{
NIR_PASS_V(nir, nir_lower_vars_to_ssa);
if (nir->info.stage == MESA_SHADER_VERTEX)
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 */
NIR_PASS_V(nir, nir_lower_vars_to_scratch, nir_var_function_temp, 16,
-2
View File
@@ -1265,8 +1265,6 @@ agx_compile_variant(struct agx_device *dev, struct agx_uncompiled_shader *so,
memcpy(opts.rt, key->blend.rt, sizeof(opts.rt));
NIR_PASS_V(nir, nir_lower_blend, &opts);
NIR_PASS_V(nir, nir_lower_fragcolor, key->nr_cbufs);
if (key->sprite_coord_enable) {
NIR_PASS_V(nir, nir_lower_texcoord_replace, key->sprite_coord_enable,
false /* point coord is sysval */, false /* Y-invert */);