static void lower_load_const_instr_scalar(nir_load_const_instr *lower) { if (lower->def.num_components == 1) return; nir_builder b; nir_builder_init(&b, nir_cf_node_get_function(&lower->instr.block->cf_node)); b.cursor = nir_before_instr(&lower->instr); /* Emit the individual loads. */ nir_ssa_def *loads[4]; for (unsigned i = 0; i < lower->def.num_components; i++) { nir_load_const_instr *load_comp = nir_load_const_instr_create(b.shader, 1); load_comp->value.u[0] = lower->value.u[i]; nir_builder_instr_insert(&b, &load_comp->instr); loads[i] = &load_comp->def; } /* Batch things back together into a vector. */ nir_ssa_def *vec = nir_vec(&b, loads, lower->def.num_components); /* Replace the old load with a reference to our reconstructed vector. */ nir_ssa_def_rewrite_uses(&lower->def, nir_src_for_ssa(vec)); nir_instr_remove(&lower->instr); }
static void convert_impl(nir_function_impl *impl) { nir_builder b; nir_builder_init(&b, impl); nir_foreach_block(impl, convert_block, &b); nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); }
static bool lower_indirects_impl(nir_function_impl *impl, nir_variable_mode modes) { nir_builder builder; nir_builder_init(&builder, impl); bool progress = false; nir_foreach_block_safe(block, impl) { progress |= lower_indirect_block(block, &builder, modes); }
static void nir_lower_tex_impl(nir_function_impl *impl, lower_tex_state *state) { nir_builder_init(&state->b, impl); nir_foreach_block(impl, nir_lower_tex_block, state); nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); }
static void lower_impl(nir_function_impl *impl, const struct gl_shader_program *shader_program, gl_shader_stage stage) { lower_state state; nir_builder_init(&state.builder, impl); state.shader_program = shader_program; state.stage = stage; nir_foreach_block(impl, lower_block_cb, &state); }
static bool nir_lower_locals_to_regs_impl(nir_function_impl *impl) { struct locals_to_regs_state state; nir_builder_init(&state.builder, impl); state.progress = false; state.regs_table = _mesa_hash_table_create(NULL, hash_deref, derefs_equal); nir_metadata_require(impl, nir_metadata_dominance); nir_foreach_block(block, impl) { lower_locals_to_regs_block(block, &state); }
static bool vc4_nir_lower_txf_ms_block(nir_block *block, void *arg) { struct vc4_compile *c = arg; nir_function_impl *impl = nir_cf_node_get_function(&block->cf_node); nir_builder b; nir_builder_init(&b, impl); nir_foreach_instr_safe(block, instr) { if (instr->type == nir_instr_type_tex) { vc4_nir_lower_txf_ms_instr(c, &b, nir_instr_as_tex(instr)); } } return true; }