gallivm/nir: split prepasses out to make per-function work easier.
authorDave Airlie <airlied@redhat.com>
Wed, 6 Sep 2023 06:33:45 +0000 (16:33 +1000)
committerMarge Bot <emma+marge@anholt.net>
Tue, 12 Sep 2023 01:57:50 +0000 (01:57 +0000)
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24687>

src/gallium/auxiliary/gallivm/lp_bld_nir.c
src/gallium/auxiliary/gallivm/lp_bld_nir.h
src/gallium/auxiliary/gallivm/lp_bld_nir_aos.c
src/gallium/auxiliary/gallivm/lp_bld_nir_soa.c

index c56326a..7fd2050 100644 (file)
@@ -2859,22 +2859,20 @@ get_register_type(struct lp_build_nir_context *bld_base,
    return type;
 }
 
-
-bool lp_build_nir_llvm(struct lp_build_nir_context *bld_base,
-                       struct nir_shader *nir)
+void
+lp_build_nir_prepasses(struct nir_shader *nir)
 {
-   struct nir_function *func;
-
    NIR_PASS_V(nir, nir_convert_to_lcssa, true, true);
    NIR_PASS_V(nir, nir_convert_from_ssa, true);
    NIR_PASS_V(nir, nir_lower_locals_to_regs, 32);
    NIR_PASS_V(nir, nir_remove_dead_derefs);
    NIR_PASS_V(nir, nir_remove_dead_variables, nir_var_function_temp, NULL);
+}
 
-   if (is_aos(bld_base)) {
-      NIR_PASS_V(nir, nir_move_vec_src_uses_to_dest);
-      NIR_PASS_V(nir, nir_lower_vec_to_regs, NULL, NULL);
-   }
+bool lp_build_nir_llvm(struct lp_build_nir_context *bld_base,
+                       struct nir_shader *nir)
+{
+   struct nir_function *func;
 
    nir_foreach_shader_out_variable(variable, nir)
       handle_shader_output_decl(bld_base, nir, variable);
index 3427bb2..443a7b4 100644 (file)
@@ -295,6 +295,8 @@ struct lp_build_nir_soa_context
    unsigned gs_vertex_streams;
 };
 
+void
+lp_build_nir_prepasses(struct nir_shader *nir);
 
 bool
 lp_build_nir_llvm(struct lp_build_nir_context *bld_base,
index 2fb53f1..f1da5b1 100644 (file)
@@ -394,5 +394,8 @@ lp_build_nir_aos(struct gallivm_state *gallivm,
    bld.bld_base.tex = emit_tex;
    bld.bld_base.emit_var_decl = emit_var_decl;
 
+   lp_build_nir_prepasses(shader);
+   NIR_PASS_V(shader, nir_move_vec_src_uses_to_dest);
+   NIR_PASS_V(shader, nir_lower_vec_to_regs, NULL, NULL);
    lp_build_nir_llvm(&bld.bld_base, shader);
 }
index 0c290cc..cd4438e 100644 (file)
@@ -2973,6 +2973,7 @@ void lp_build_nir_soa(struct gallivm_state *gallivm,
    }
 
    emit_prologue(&bld);
+   lp_build_nir_prepasses(shader);
    lp_build_nir_llvm(&bld.bld_base, shader);
 
    if (bld.gs_iface) {