Mesa (master): pan/mdg: Use nir_shader_instructions_pass for fdot2 lowering
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Sun Sep 20 01:48:37 UTC 2020
Module: Mesa
Branch: master
Commit: 27516baa2aebe815dca011957d45e15f5b319fd6
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=27516baa2aebe815dca011957d45e15f5b319fd6
Author: Icecream95 <ixn at keemail.me>
Date: Sat Sep 5 17:00:37 2020 +1200
pan/mdg: Use nir_shader_instructions_pass for fdot2 lowering
Reviewed-by: Eric Anholt <eric at anholt.net>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6718>
---
src/panfrost/midgard/midgard_compile.c | 41 +++++++++++-----------------------
1 file changed, 13 insertions(+), 28 deletions(-)
diff --git a/src/panfrost/midgard/midgard_compile.c b/src/panfrost/midgard/midgard_compile.c
index 415000b9825..79b41818398 100644
--- a/src/panfrost/midgard/midgard_compile.c
+++ b/src/panfrost/midgard/midgard_compile.c
@@ -174,11 +174,15 @@ glsl_type_size(const struct glsl_type *type, bool bindless)
}
/* Lower fdot2 to a vector multiplication followed by channel addition */
-static void
-midgard_nir_lower_fdot2_body(nir_builder *b, nir_alu_instr *alu)
+static bool
+midgard_nir_lower_fdot2_instr(nir_builder *b, nir_instr *instr, void *data)
{
+ if (instr->type != nir_instr_type_alu)
+ return false;
+
+ nir_alu_instr *alu = nir_instr_as_alu(instr);
if (alu->op != nir_op_fdot2)
- return;
+ return false;
b->cursor = nir_before_instr(&alu->instr);
@@ -193,36 +197,17 @@ midgard_nir_lower_fdot2_body(nir_builder *b, nir_alu_instr *alu)
/* Replace the fdot2 with this sum */
nir_ssa_def_rewrite_uses(&alu->dest.dest.ssa, nir_src_for_ssa(sum));
+
+ return true;
}
static bool
midgard_nir_lower_fdot2(nir_shader *shader)
{
- bool progress = false;
-
- nir_foreach_function(function, shader) {
- if (!function->impl) continue;
-
- nir_builder _b;
- nir_builder *b = &_b;
- nir_builder_init(b, function->impl);
-
- nir_foreach_block(block, function->impl) {
- nir_foreach_instr_safe(instr, block) {
- if (instr->type != nir_instr_type_alu) continue;
-
- nir_alu_instr *alu = nir_instr_as_alu(instr);
- midgard_nir_lower_fdot2_body(b, alu);
-
- progress |= true;
- }
- }
-
- nir_metadata_preserve(function->impl, nir_metadata_block_index | nir_metadata_dominance);
-
- }
-
- return progress;
+ return nir_shader_instructions_pass(shader,
+ midgard_nir_lower_fdot2_instr,
+ nir_metadata_block_index | nir_metadata_dominance,
+ NULL);
}
static const nir_variable *
More information about the mesa-commit
mailing list