xref: /aosp_15_r20/external/mesa3d/src/freedreno/ir3/ir3_nir_lower_push_consts_to_preamble.c (revision 6104692788411f58d303aa86923a9ff6ecaded22)
1 /*
2  * Copyright © 2023 Igalia S.L.
3  * SPDX-License-Identifier: MIT
4  */
5 
6 #include "compiler/nir/nir.h"
7 #include "compiler/nir/nir_builder.h"
8 #include "util/u_math.h"
9 #include "ir3_compiler.h"
10 #include "ir3_nir.h"
11 
12 bool
ir3_nir_lower_push_consts_to_preamble(nir_shader * nir,struct ir3_shader_variant * v)13 ir3_nir_lower_push_consts_to_preamble(nir_shader *nir,
14                                       struct ir3_shader_variant *v)
15 {
16    nir_function_impl *preamble = nir_shader_get_preamble(nir);
17    nir_builder _b = nir_builder_at(nir_before_impl(preamble));
18    nir_builder *b = &_b;
19 
20    nir_copy_push_const_to_uniform_ir3(
21       b, nir_imm_int(b, 0), .base = v->shader_options.push_consts_base,
22       .range = v->shader_options.push_consts_dwords);
23 
24    nir_foreach_function_impl(impl, nir) {
25       nir_metadata_preserve(impl, nir_metadata_none);
26    }
27    return true;
28 }
29