From 6908a0decea295ed9b99825dd8a44bcd3371d059 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 28 Nov 2022 22:37:31 -0500 Subject: [PATCH] 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 Part-of: --- src/asahi/compiler/agx_compile.c | 9 ++++++++- src/gallium/drivers/asahi/agx_state.c | 2 -- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index cd7724c..d75e6ae 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -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, diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index 474a93e..f47747b 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -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 */); -- 2.7.4