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)13ir3_nir_lower_push_consts_to_preamble(nir_shader *nir, 14 struct ir3_shader_variant *v) 15 { 16 const struct ir3_const_state *const_state = ir3_const_state(v); 17 nir_function_impl *preamble = nir_shader_get_preamble(nir); 18 nir_builder _b = nir_builder_at(nir_before_impl(preamble)); 19 nir_builder *b = &_b; 20 21 uint32_t offset_vec4 = 22 const_state->allocs.consts[IR3_CONST_ALLOC_PUSH_CONSTS].offset_vec4 * 4; 23 nir_copy_push_const_to_uniform_ir3( 24 b, nir_imm_int(b, offset_vec4), 25 .base = v->shader_options.push_consts_base, 26 .range = v->shader_options.push_consts_dwords); 27 28 nir_foreach_function_impl(impl, nir) { 29 nir_metadata_preserve(impl, nir_metadata_none); 30 } 31 return true; 32 } 33