diff options
author | Connor Abbott <[email protected]> | 2016-04-12 22:56:14 -0400 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2016-04-28 15:52:17 -0700 |
commit | 7efff10585122d484dc3adab14af9380b9b8f309 (patch) | |
tree | f0e5e2c59224d1951b30de9f6fe66e23f5994d6a /src | |
parent | 3a8688fb4103ed6f21d1311a9331efff456294b0 (diff) |
i965/nir: fixup for new foreach_block()
Reviewed-by: Jason Ekstrand <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 7 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_nir.c | 90 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c | 6 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_nir_attribute_workarounds.c | 7 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c | 31 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4_nir.cpp | 8 |
6 files changed, 69 insertions, 80 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp index 3d7013f1bdd..fcc8ee6e8f2 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_nir.cpp @@ -181,9 +181,8 @@ fs_visitor::nir_setup_uniforms() } static bool -emit_system_values_block(nir_block *block, void *void_visitor) +emit_system_values_block(nir_block *block, fs_visitor *v) { - fs_visitor *v = (fs_visitor *)void_visitor; fs_reg *reg; nir_foreach_instr(block, instr) { @@ -348,7 +347,9 @@ fs_visitor::nir_emit_system_values() nir_foreach_function(nir, function) { assert(strcmp(function->name, "main") == 0); assert(function->impl); - nir_foreach_block_call(function->impl, emit_system_values_block, this); + nir_foreach_block(block, function->impl) { + emit_system_values_block(block, this); + } } } diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c index f9bcba292bd..3dd5f0785cf 100644 --- a/src/mesa/drivers/dri/i965/brw_nir.c +++ b/src/mesa/drivers/dri/i965/brw_nir.c @@ -54,25 +54,19 @@ is_output(nir_intrinsic_instr *intrin) * we don't know what part of a compound variable is accessed, we allocate * storage for the entire thing. */ -struct add_const_offset_to_base_params { - nir_builder b; - nir_variable_mode mode; -}; static bool -add_const_offset_to_base_block(nir_block *block, void *closure) +add_const_offset_to_base_block(nir_block *block, nir_builder *b, + nir_variable_mode mode) { - struct add_const_offset_to_base_params *params = closure; - nir_builder *b = ¶ms->b; - nir_foreach_instr_safe(block, instr) { if (instr->type != nir_instr_type_intrinsic) continue; nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); - if ((params->mode == nir_var_shader_in && is_input(intrin)) || - (params->mode == nir_var_shader_out && is_output(intrin))) { + if ((mode == nir_var_shader_in && is_input(intrin)) || + (mode == nir_var_shader_out && is_output(intrin))) { nir_src *offset = nir_get_io_offset_src(intrin); nir_const_value *const_offset = nir_src_as_const_value(*offset); @@ -90,21 +84,20 @@ add_const_offset_to_base_block(nir_block *block, void *closure) static void add_const_offset_to_base(nir_shader *nir, nir_variable_mode mode) { - struct add_const_offset_to_base_params params = { .mode = mode }; - nir_foreach_function(nir, f) { if (f->impl) { - nir_builder_init(¶ms.b, f->impl); - nir_foreach_block_call(f->impl, add_const_offset_to_base_block, ¶ms); + nir_builder b; + nir_builder_init(&b, f->impl); + nir_foreach_block(block, f->impl) { + add_const_offset_to_base_block(block, &b, mode); + } } } } static bool -remap_vs_attrs(nir_block *block, void *closure) +remap_vs_attrs(nir_block *block, GLbitfield64 inputs_read) { - GLbitfield64 inputs_read = *((GLbitfield64 *) closure); - nir_foreach_instr(block, instr) { if (instr->type != nir_instr_type_intrinsic) continue; @@ -127,10 +120,8 @@ remap_vs_attrs(nir_block *block, void *closure) } static bool -remap_inputs_with_vue_map(nir_block *block, void *closure) +remap_inputs_with_vue_map(nir_block *block, const struct brw_vue_map *vue_map) { - const struct brw_vue_map *vue_map = closure; - nir_foreach_instr(block, instr) { if (instr->type != nir_instr_type_intrinsic) continue; @@ -147,27 +138,21 @@ remap_inputs_with_vue_map(nir_block *block, void *closure) return true; } -struct remap_patch_urb_offsets_state { - nir_builder b; - const struct brw_vue_map *vue_map; -}; - static bool -remap_patch_urb_offsets(nir_block *block, void *closure) +remap_patch_urb_offsets(nir_block *block, nir_builder *b, + const struct brw_vue_map *vue_map) { - struct remap_patch_urb_offsets_state *state = closure; - nir_foreach_instr_safe(block, instr) { if (instr->type != nir_instr_type_intrinsic) continue; nir_intrinsic_instr *intrin = nir_instr_as_intrinsic(instr); - gl_shader_stage stage = state->b.shader->stage; + gl_shader_stage stage = b->shader->stage; if ((stage == MESA_SHADER_TESS_CTRL && is_output(intrin)) || (stage == MESA_SHADER_TESS_EVAL && is_input(intrin))) { - int vue_slot = state->vue_map->varying_to_slot[intrin->const_index[0]]; + int vue_slot = vue_map->varying_to_slot[intrin->const_index[0]]; assert(vue_slot != -1); intrin->const_index[0] = vue_slot; @@ -176,22 +161,22 @@ remap_patch_urb_offsets(nir_block *block, void *closure) nir_const_value *const_vertex = nir_src_as_const_value(*vertex); if (const_vertex) { intrin->const_index[0] += const_vertex->u32[0] * - state->vue_map->num_per_vertex_slots; + vue_map->num_per_vertex_slots; } else { - state->b.cursor = nir_before_instr(&intrin->instr); + b->cursor = nir_before_instr(&intrin->instr); /* Multiply by the number of per-vertex slots. */ nir_ssa_def *vertex_offset = - nir_imul(&state->b, - nir_ssa_for_src(&state->b, *vertex, 1), - nir_imm_int(&state->b, - state->vue_map->num_per_vertex_slots)); + nir_imul(b, + nir_ssa_for_src(b, *vertex, 1), + nir_imm_int(b, + vue_map->num_per_vertex_slots)); /* Add it to the existing offset */ nir_src *offset = nir_get_io_offset_src(intrin); nir_ssa_def *total_offset = - nir_iadd(&state->b, vertex_offset, - nir_ssa_for_src(&state->b, *offset, 1)); + nir_iadd(b, vertex_offset, + nir_ssa_for_src(b, *offset, 1)); nir_instr_rewrite_src(&intrin->instr, offset, nir_src_for_ssa(total_offset)); @@ -239,7 +224,9 @@ brw_nir_lower_vs_inputs(nir_shader *nir, nir_foreach_function(nir, function) { if (function->impl) { - nir_foreach_block_call(function->impl, remap_vs_attrs, &inputs_read); + nir_foreach_block(block, function->impl) { + remap_vs_attrs(block, inputs_read); + } } } } @@ -264,8 +251,9 @@ brw_nir_lower_vue_inputs(nir_shader *nir, bool is_scalar, nir_foreach_function(nir, function) { if (function->impl) { - nir_foreach_block_call(function->impl, remap_inputs_with_vue_map, - (void *) vue_map); + nir_foreach_block(block, function->impl) { + remap_inputs_with_vue_map(block, vue_map); + } } } } @@ -274,9 +262,6 @@ brw_nir_lower_vue_inputs(nir_shader *nir, bool is_scalar, void brw_nir_lower_tes_inputs(nir_shader *nir, const struct brw_vue_map *vue_map) { - struct remap_patch_urb_offsets_state state; - state.vue_map = vue_map; - foreach_list_typed(nir_variable, var, node, &nir->inputs) { var->data.driver_location = var->data.location; } @@ -290,8 +275,11 @@ brw_nir_lower_tes_inputs(nir_shader *nir, const struct brw_vue_map *vue_map) nir_foreach_function(nir, function) { if (function->impl) { - nir_builder_init(&state.b, function->impl); - nir_foreach_block_call(function->impl, remap_patch_urb_offsets, &state); + nir_builder b; + nir_builder_init(&b, function->impl); + nir_foreach_block(block, function->impl) { + remap_patch_urb_offsets(block, &b, vue_map); + } } } } @@ -321,9 +309,6 @@ brw_nir_lower_vue_outputs(nir_shader *nir, void brw_nir_lower_tcs_outputs(nir_shader *nir, const struct brw_vue_map *vue_map) { - struct remap_patch_urb_offsets_state state; - state.vue_map = vue_map; - nir_foreach_variable(var, &nir->outputs) { var->data.driver_location = var->data.location; } @@ -337,8 +322,11 @@ brw_nir_lower_tcs_outputs(nir_shader *nir, const struct brw_vue_map *vue_map) nir_foreach_function(nir, function) { if (function->impl) { - nir_builder_init(&state.b, function->impl); - nir_foreach_block_call(function->impl, remap_patch_urb_offsets, &state); + nir_builder b; + nir_builder_init(&b, function->impl); + nir_foreach_block(block, function->impl) { + remap_patch_urb_offsets(block, &b, vue_map); + } } } } diff --git a/src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c b/src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c index 69499f76754..e09329fc0d4 100644 --- a/src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c +++ b/src/mesa/drivers/dri/i965/brw_nir_analyze_boolean_resolves.c @@ -84,7 +84,7 @@ src_mark_needs_resolve(nir_src *src, void *void_state) } static bool -analyze_boolean_resolves_block(nir_block *block, void *void_state) +analyze_boolean_resolves_block(nir_block *block) { nir_foreach_instr(block, instr) { switch (instr->type) { @@ -254,7 +254,9 @@ analyze_boolean_resolves_block(nir_block *block, void *void_state) static void analyze_boolean_resolves_impl(nir_function_impl *impl) { - nir_foreach_block_call(impl, analyze_boolean_resolves_block, NULL); + nir_foreach_block(block, impl) { + analyze_boolean_resolves_block(block); + } } void diff --git a/src/mesa/drivers/dri/i965/brw_nir_attribute_workarounds.c b/src/mesa/drivers/dri/i965/brw_nir_attribute_workarounds.c index 57cc07da6e6..c21e16d6508 100644 --- a/src/mesa/drivers/dri/i965/brw_nir_attribute_workarounds.c +++ b/src/mesa/drivers/dri/i965/brw_nir_attribute_workarounds.c @@ -39,9 +39,8 @@ struct attr_wa_state { }; static bool -apply_attr_wa_block(nir_block *block, void *void_state) +apply_attr_wa_block(nir_block *block, struct attr_wa_state *state) { - struct attr_wa_state *state = void_state; nir_builder *b = &state->builder; nir_foreach_instr_safe(block, instr) { @@ -163,7 +162,9 @@ brw_nir_apply_attribute_workarounds(nir_shader *shader, nir_builder_init(&state.builder, func->impl); state.impl_progress = false; - nir_foreach_block_call(func->impl, apply_attr_wa_block, &state); + nir_foreach_block(block, func->impl) { + apply_attr_wa_block(block, &state); + } if (state.impl_progress) { nir_metadata_preserve(func->impl, nir_metadata_block_index | diff --git a/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c b/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c index a38f721c45e..b571bb9b8d3 100644 --- a/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c +++ b/src/mesa/drivers/dri/i965/brw_nir_opt_peephole_ffma.c @@ -167,9 +167,9 @@ any_alu_src_is_a_constant(nir_alu_src srcs[]) } static bool -brw_nir_opt_peephole_ffma_block(nir_block *block, void *void_state) +brw_nir_opt_peephole_ffma_block(nir_block *block, void *mem_ctx) { - struct peephole_ffma_state *state = void_state; + bool progress = false; nir_foreach_instr_safe(block, instr) { if (instr->type != nir_instr_type_alu) @@ -231,8 +231,7 @@ brw_nir_opt_peephole_ffma_block(nir_block *block, void *void_state) if (abs) { for (unsigned i = 0; i < 2; i++) { - nir_alu_instr *abs = nir_alu_instr_create(state->mem_ctx, - nir_op_fabs); + nir_alu_instr *abs = nir_alu_instr_create(mem_ctx, nir_op_fabs); abs->src[0].src = nir_src_for_ssa(mul_src[i]); nir_ssa_dest_init(&abs->instr, &abs->dest.dest, mul_src[i]->num_components, bit_size, NULL); @@ -243,8 +242,7 @@ brw_nir_opt_peephole_ffma_block(nir_block *block, void *void_state) } if (negate) { - nir_alu_instr *neg = nir_alu_instr_create(state->mem_ctx, - nir_op_fneg); + nir_alu_instr *neg = nir_alu_instr_create(mem_ctx, nir_op_fneg); neg->src[0].src = nir_src_for_ssa(mul_src[0]); nir_ssa_dest_init(&neg->instr, &neg->dest.dest, mul_src[0]->num_components, bit_size, NULL); @@ -253,7 +251,7 @@ brw_nir_opt_peephole_ffma_block(nir_block *block, void *void_state) mul_src[0] = &neg->dest.dest.ssa; } - nir_alu_instr *ffma = nir_alu_instr_create(state->mem_ctx, nir_op_ffma); + nir_alu_instr *ffma = nir_alu_instr_create(mem_ctx, nir_op_ffma); ffma->dest.saturate = add->dest.saturate; ffma->dest.write_mask = add->dest.write_mask; @@ -277,28 +275,27 @@ brw_nir_opt_peephole_ffma_block(nir_block *block, void *void_state) assert(list_empty(&add->dest.dest.ssa.uses)); nir_instr_remove(&add->instr); - state->progress = true; + progress = true; } - return true; + return progress; } static bool brw_nir_opt_peephole_ffma_impl(nir_function_impl *impl) { - struct peephole_ffma_state state; - - state.mem_ctx = ralloc_parent(impl); - state.impl = impl; - state.progress = false; + bool progress = false; + void *mem_ctx = ralloc_parent(impl); - nir_foreach_block_call(impl, brw_nir_opt_peephole_ffma_block, &state); + nir_foreach_block(block, impl) { + progress |= brw_nir_opt_peephole_ffma_block(block, mem_ctx); + } - if (state.progress) + if (progress) nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance); - return state.progress; + return progress; } bool diff --git a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp index 6bed6508d62..2694905cb7e 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_nir.cpp @@ -98,10 +98,8 @@ vec4_visitor::nir_setup_system_value_intrinsic(nir_intrinsic_instr *instr) } static bool -setup_system_values_block(nir_block *block, void *void_visitor) +setup_system_values_block(nir_block *block, vec4_visitor *v) { - vec4_visitor *v = (vec4_visitor *)void_visitor; - nir_foreach_instr(block, instr) { if (instr->type != nir_instr_type_intrinsic) continue; @@ -124,7 +122,9 @@ vec4_visitor::nir_setup_system_values() nir_foreach_function(nir, function) { assert(strcmp(function->name, "main") == 0); assert(function->impl); - nir_foreach_block_call(function->impl, setup_system_values_block, this); + nir_foreach_block(block, function->impl) { + setup_system_values_block(block, this); + } } } |