treewide: Remove all usage of nir_builder_init with nir_builder_create and nir_builder_at
Signed-off-by: Yonggang Luo <luoyonggang@gmail.com> Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24038>
This commit is contained in:
@@ -1080,11 +1080,8 @@ ac_nir_lower_legacy_gs(nir_shader *nir,
|
|||||||
|
|
||||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||||
|
|
||||||
nir_builder builder;
|
nir_builder builder = nir_builder_at(nir_after_cf_list(&impl->body));
|
||||||
nir_builder *b = &builder;
|
nir_builder *b = &builder;
|
||||||
nir_builder_init(b, impl);
|
|
||||||
|
|
||||||
b->cursor = nir_after_cf_list(&impl->body);
|
|
||||||
|
|
||||||
/* Emit shader query for mix use legacy/NGG GS */
|
/* Emit shader query for mix use legacy/NGG GS */
|
||||||
bool progress = ac_nir_gs_shader_query(b,
|
bool progress = ac_nir_gs_shader_query(b,
|
||||||
|
@@ -2363,9 +2363,8 @@ ac_nir_lower_ngg_nogs(nir_shader *shader, const ac_nir_lower_ngg_options *option
|
|||||||
shader->info.outputs_written |= VARYING_BIT_PRIMITIVE_ID;
|
shader->info.outputs_written |= VARYING_BIT_PRIMITIVE_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
nir_builder builder;
|
nir_builder builder = nir_builder_create(impl);
|
||||||
nir_builder *b = &builder; /* This is to avoid the & */
|
nir_builder *b = &builder; /* This is to avoid the & */
|
||||||
nir_builder_init(b, impl);
|
|
||||||
|
|
||||||
if (options->can_cull) {
|
if (options->can_cull) {
|
||||||
analyze_shader_before_culling(shader, &state);
|
analyze_shader_before_culling(shader, &state);
|
||||||
@@ -3440,10 +3439,8 @@ ac_nir_lower_ngg_gs(nir_shader *shader, const ac_nir_lower_ngg_options *options)
|
|||||||
nir_cf_list extracted;
|
nir_cf_list extracted;
|
||||||
nir_cf_extract(&extracted, nir_before_cf_list(&impl->body), nir_after_cf_list(&impl->body));
|
nir_cf_extract(&extracted, nir_before_cf_list(&impl->body), nir_after_cf_list(&impl->body));
|
||||||
|
|
||||||
nir_builder builder;
|
nir_builder builder = nir_builder_at(nir_before_cf_list(&impl->body));
|
||||||
nir_builder *b = &builder; /* This is to avoid the & */
|
nir_builder *b = &builder; /* This is to avoid the & */
|
||||||
nir_builder_init(b, impl);
|
|
||||||
b->cursor = nir_before_cf_list(&impl->body);
|
|
||||||
|
|
||||||
/* Workgroup barrier: wait for ES threads */
|
/* Workgroup barrier: wait for ES threads */
|
||||||
nir_scoped_barrier(b, .execution_scope=SCOPE_WORKGROUP, .memory_scope=SCOPE_WORKGROUP,
|
nir_scoped_barrier(b, .execution_scope=SCOPE_WORKGROUP, .memory_scope=SCOPE_WORKGROUP,
|
||||||
@@ -4767,10 +4764,8 @@ ac_nir_lower_ngg_ms(nir_shader *shader,
|
|||||||
state.primitive_count_var =
|
state.primitive_count_var =
|
||||||
nir_local_variable_create(impl, glsl_uint_type(), "primitive_count_var");
|
nir_local_variable_create(impl, glsl_uint_type(), "primitive_count_var");
|
||||||
|
|
||||||
nir_builder builder;
|
nir_builder builder = nir_builder_at(nir_before_cf_list(&impl->body));
|
||||||
nir_builder *b = &builder; /* This is to avoid the & */
|
nir_builder *b = &builder; /* This is to avoid the & */
|
||||||
nir_builder_init(b, impl);
|
|
||||||
b->cursor = nir_before_cf_list(&impl->body);
|
|
||||||
|
|
||||||
handle_smaller_ms_api_workgroup(b, &state);
|
handle_smaller_ms_api_workgroup(b, &state);
|
||||||
ms_emit_legacy_workgroup_index(b, &state);
|
ms_emit_legacy_workgroup_index(b, &state);
|
||||||
|
@@ -853,9 +853,8 @@ ac_nir_lower_ps(nir_shader *nir, const ac_nir_lower_ps_options *options)
|
|||||||
{
|
{
|
||||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||||
|
|
||||||
nir_builder builder;
|
nir_builder builder = nir_builder_create(impl);
|
||||||
nir_builder *b = &builder;
|
nir_builder *b = &builder;
|
||||||
nir_builder_init(b, impl);
|
|
||||||
|
|
||||||
lower_ps_state state = {
|
lower_ps_state state = {
|
||||||
.options = options,
|
.options = options,
|
||||||
|
@@ -559,10 +559,8 @@ hs_emit_write_tess_factors(nir_shader *shader,
|
|||||||
|
|
||||||
/* We assume there is always a single end block in the shader. */
|
/* We assume there is always a single end block in the shader. */
|
||||||
|
|
||||||
nir_builder builder;
|
nir_builder builder = nir_builder_at(nir_after_block(last_block));
|
||||||
nir_builder *b = &builder; /* This is to avoid the & */
|
nir_builder *b = &builder; /* This is to avoid the & */
|
||||||
nir_builder_init(b, impl);
|
|
||||||
b->cursor = nir_after_block(last_block);
|
|
||||||
|
|
||||||
/* If tess factors are load from LDS, wait previous LDS stores done. */
|
/* If tess factors are load from LDS, wait previous LDS stores done. */
|
||||||
if (!st->tcs_pass_tessfactors_by_reg) {
|
if (!st->tcs_pass_tessfactors_by_reg) {
|
||||||
|
@@ -495,9 +495,7 @@ gl_nir_lower_blend_equation_advanced(nir_shader *sh, bool coherent)
|
|||||||
|
|
||||||
sh->info.fs.uses_sample_shading = true;
|
sh->info.fs.uses_sample_shading = true;
|
||||||
|
|
||||||
nir_builder b;
|
nir_builder b = nir_builder_at(nir_after_block(nir_impl_last_block(impl)));
|
||||||
nir_builder_init(&b, impl);
|
|
||||||
b.cursor = nir_after_block(nir_impl_last_block(impl));
|
|
||||||
|
|
||||||
nir_variable *fb = nir_variable_create(sh, nir_var_shader_out,
|
nir_variable *fb = nir_variable_create(sh, nir_var_shader_out,
|
||||||
glsl_vec4_type(),
|
glsl_vec4_type(),
|
||||||
|
@@ -524,10 +524,8 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options,
|
|||||||
_mesa_pointer_hash_table_create(NULL);
|
_mesa_pointer_hash_table_create(NULL);
|
||||||
nir_function_impl *preamble =
|
nir_function_impl *preamble =
|
||||||
nir_shader_get_preamble(impl->function->shader);
|
nir_shader_get_preamble(impl->function->shader);
|
||||||
nir_builder _b;
|
nir_builder preamble_builder = nir_builder_at(nir_before_cf_list(&preamble->body));
|
||||||
nir_builder *b = &_b;
|
nir_builder *b = &preamble_builder;
|
||||||
nir_builder_init(b, preamble);
|
|
||||||
b->cursor = nir_before_cf_list(&preamble->body);
|
|
||||||
|
|
||||||
nir_foreach_block (block, impl) {
|
nir_foreach_block (block, impl) {
|
||||||
nir_foreach_instr (instr, block) {
|
nir_foreach_instr (instr, block) {
|
||||||
@@ -570,7 +568,8 @@ nir_opt_preamble(nir_shader *shader, const nir_opt_preamble_options *options,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nir_builder_init(b, impl);
|
nir_builder builder = nir_builder_create(impl);
|
||||||
|
b = &builder;
|
||||||
|
|
||||||
nir_foreach_block (block, impl) {
|
nir_foreach_block (block, impl) {
|
||||||
nir_foreach_instr_safe (instr, block) {
|
nir_foreach_instr_safe (instr, block) {
|
||||||
|
@@ -350,9 +350,8 @@ copy_ubo_to_uniform(nir_shader *nir, const struct ir3_const_state *const_state)
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
nir_function_impl *preamble = nir_shader_get_preamble(nir);
|
nir_function_impl *preamble = nir_shader_get_preamble(nir);
|
||||||
nir_builder _b, *b = &_b;
|
nir_builder _b = nir_builder_at(nir_after_cf_list(&preamble->body));
|
||||||
nir_builder_init(b, preamble);
|
nir_builder *b = &_b;
|
||||||
b->cursor = nir_after_cf_list(&preamble->body);
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < state->num_enabled; i++) {
|
for (unsigned i = 0; i < state->num_enabled; i++) {
|
||||||
const struct ir3_ubo_range *range = &state->range[i];
|
const struct ir3_ubo_range *range = &state->range[i];
|
||||||
|
@@ -310,9 +310,8 @@ ir3_nir_lower_preamble(nir_shader *nir, struct ir3_shader_variant *v)
|
|||||||
BITSET_DECLARE(promoted_to_float, preamble_size);
|
BITSET_DECLARE(promoted_to_float, preamble_size);
|
||||||
memset(promoted_to_float, 0, sizeof(promoted_to_float));
|
memset(promoted_to_float, 0, sizeof(promoted_to_float));
|
||||||
|
|
||||||
nir_builder _b;
|
nir_builder builder_main = nir_builder_create(main);
|
||||||
nir_builder *b = &_b;
|
nir_builder *b = &builder_main;
|
||||||
nir_builder_init(b, main);
|
|
||||||
|
|
||||||
nir_foreach_block (block, main) {
|
nir_foreach_block (block, main) {
|
||||||
nir_foreach_instr_safe (instr, block) {
|
nir_foreach_instr_safe (instr, block) {
|
||||||
@@ -350,7 +349,8 @@ ir3_nir_lower_preamble(nir_shader *nir, struct ir3_shader_variant *v)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nir_builder_init(b, preamble);
|
nir_builder builder_preamble = nir_builder_create(preamble);
|
||||||
|
b = &builder_preamble;
|
||||||
|
|
||||||
nir_foreach_block (block, preamble) {
|
nir_foreach_block (block, preamble) {
|
||||||
nir_foreach_instr_safe (instr, block) {
|
nir_foreach_instr_safe (instr, block) {
|
||||||
|
@@ -104,9 +104,7 @@ static void
|
|||||||
nir_lower_pstipple_impl(nir_function_impl *impl,
|
nir_lower_pstipple_impl(nir_function_impl *impl,
|
||||||
lower_pstipple *state)
|
lower_pstipple *state)
|
||||||
{
|
{
|
||||||
nir_builder *b = &state->b;
|
state->b = nir_builder_create(impl);
|
||||||
|
|
||||||
nir_builder_init(b, impl);
|
|
||||||
|
|
||||||
nir_block *start = nir_start_block(impl);
|
nir_block *start = nir_start_block(impl);
|
||||||
nir_lower_pstipple_block(start, state);
|
nir_lower_pstipple_block(start, state);
|
||||||
@@ -313,13 +311,10 @@ static void
|
|||||||
nir_lower_aapoint_impl(nir_function_impl *impl, lower_aapoint *state,
|
nir_lower_aapoint_impl(nir_function_impl *impl, lower_aapoint *state,
|
||||||
nir_alu_type bool_type)
|
nir_alu_type bool_type)
|
||||||
{
|
{
|
||||||
nir_builder *b = &state->b;
|
|
||||||
|
|
||||||
nir_builder_init(b, impl);
|
|
||||||
|
|
||||||
nir_block *block = nir_start_block(impl);
|
nir_block *block = nir_start_block(impl);
|
||||||
b->cursor = nir_before_block(block);
|
state->b = nir_builder_at(nir_before_block(block));
|
||||||
|
|
||||||
|
nir_builder *b = &state->b;
|
||||||
nir_ssa_def *aainput = nir_load_var(b, state->input);
|
nir_ssa_def *aainput = nir_load_var(b, state->input);
|
||||||
|
|
||||||
nir_ssa_def *dist = nir_fadd(b, nir_fmul(b, nir_channel(b, aainput, 0), nir_channel(b, aainput, 0)),
|
nir_ssa_def *dist = nir_fadd(b, nir_fmul(b, nir_channel(b, aainput, 0), nir_channel(b, aainput, 0)),
|
||||||
|
@@ -530,12 +530,11 @@ r600_append_tcs_TF_emission(nir_shader *shader, enum mesa_prim prim_type)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nir_builder builder;
|
|
||||||
nir_builder *b = &builder;
|
|
||||||
|
|
||||||
assert(exec_list_length(&shader->functions) == 1);
|
assert(exec_list_length(&shader->functions) == 1);
|
||||||
nir_function *f = (nir_function *)shader->functions.get_head();
|
nir_function *f = (nir_function *)shader->functions.get_head();
|
||||||
nir_builder_init(b, f->impl);
|
nir_builder builder = nir_builder_create(f->impl);
|
||||||
|
nir_builder *b = &builder;
|
||||||
|
|
||||||
auto outer_comps = outer_tf_components(prim_type);
|
auto outer_comps = outer_tf_components(prim_type);
|
||||||
if (!outer_comps)
|
if (!outer_comps)
|
||||||
|
@@ -1931,11 +1931,8 @@ static void si_nir_lower_ps_color_input(nir_shader *nir, struct si_shader *shade
|
|||||||
{
|
{
|
||||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||||
|
|
||||||
nir_builder builder;
|
nir_builder builder = nir_builder_at(nir_before_cf_list(&impl->body));
|
||||||
nir_builder *b = &builder;
|
nir_builder *b = &builder;
|
||||||
nir_builder_init(b, impl);
|
|
||||||
|
|
||||||
b->cursor = nir_before_cf_list(&impl->body);
|
|
||||||
|
|
||||||
const struct si_shader_selector *sel = shader->selector;
|
const struct si_shader_selector *sel = shader->selector;
|
||||||
const union si_shader_key *key = &shader->key;
|
const union si_shader_key *key = &shader->key;
|
||||||
@@ -2015,11 +2012,8 @@ static void si_nir_emit_polygon_stipple(nir_shader *nir, struct si_shader_args *
|
|||||||
{
|
{
|
||||||
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
nir_function_impl *impl = nir_shader_get_entrypoint(nir);
|
||||||
|
|
||||||
nir_builder builder;
|
nir_builder builder = nir_builder_at(nir_before_cf_list(&impl->body));
|
||||||
nir_builder *b = &builder;
|
nir_builder *b = &builder;
|
||||||
nir_builder_init(b, impl);
|
|
||||||
|
|
||||||
b->cursor = nir_before_cf_list(&impl->body);
|
|
||||||
|
|
||||||
/* Load the buffer descriptor. */
|
/* Load the buffer descriptor. */
|
||||||
nir_ssa_def *desc =
|
nir_ssa_def *desc =
|
||||||
|
@@ -56,12 +56,11 @@ load_clc_shader(struct brw_compiler *compiler, struct disk_cache *disk_cache,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static nir_builder
|
||||||
builder_init_new_impl(nir_builder *b, nir_function *func)
|
builder_init_new_impl(nir_function *func)
|
||||||
{
|
{
|
||||||
nir_function_impl *impl = nir_function_impl_create(func);
|
nir_function_impl *impl = nir_function_impl_create(func);
|
||||||
nir_builder_init(b, impl);
|
return nir_builder_at(nir_before_cf_list(&impl->body));
|
||||||
b->cursor = nir_before_cf_list(&impl->body);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -69,9 +68,7 @@ implement_atomic_builtin(nir_function *func, nir_atomic_op atomic_op,
|
|||||||
enum glsl_base_type data_base_type,
|
enum glsl_base_type data_base_type,
|
||||||
nir_variable_mode mode)
|
nir_variable_mode mode)
|
||||||
{
|
{
|
||||||
nir_builder b;
|
nir_builder b = builder_init_new_impl(func);
|
||||||
builder_init_new_impl(&b, func);
|
|
||||||
|
|
||||||
const struct glsl_type *data_type = glsl_scalar_type(data_base_type);
|
const struct glsl_type *data_type = glsl_scalar_type(data_base_type);
|
||||||
|
|
||||||
unsigned p = 0;
|
unsigned p = 0;
|
||||||
@@ -103,9 +100,7 @@ implement_atomic_builtin(nir_function *func, nir_atomic_op atomic_op,
|
|||||||
static void
|
static void
|
||||||
implement_sub_group_ballot_builtin(nir_function *func)
|
implement_sub_group_ballot_builtin(nir_function *func)
|
||||||
{
|
{
|
||||||
nir_builder b;
|
nir_builder b = builder_init_new_impl(func);
|
||||||
builder_init_new_impl(&b, func);
|
|
||||||
|
|
||||||
nir_deref_instr *ret =
|
nir_deref_instr *ret =
|
||||||
nir_build_deref_cast(&b, nir_load_param(&b, 0),
|
nir_build_deref_cast(&b, nir_load_param(&b, 0),
|
||||||
nir_var_function_temp, glsl_uint_type(), 0);
|
nir_var_function_temp, glsl_uint_type(), 0);
|
||||||
|
@@ -144,8 +144,8 @@ anv_nir_compute_push_layout(nir_shader *nir,
|
|||||||
|
|
||||||
if (has_push_intrinsic) {
|
if (has_push_intrinsic) {
|
||||||
nir_foreach_function_impl(impl, nir) {
|
nir_foreach_function_impl(impl, nir) {
|
||||||
nir_builder build, *b = &build;
|
nir_builder build = nir_builder_create(impl);
|
||||||
nir_builder_init(b, impl);
|
nir_builder *b = &build;
|
||||||
|
|
||||||
nir_foreach_block(block, impl) {
|
nir_foreach_block(block, impl) {
|
||||||
nir_foreach_instr_safe(instr, block) {
|
nir_foreach_instr_safe(instr, block) {
|
||||||
|
Reference in New Issue
Block a user