mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-28 04:20:40 +02:00
nir: Convert to nir_foreach_function_impl
Done by hand at each call site but going very quickly with funny Vim motions and common regexes. This is a very common idiom in NIR. Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23807>
This commit is contained in:
parent
19daa9283c
commit
190b1fdc64
93 changed files with 570 additions and 798 deletions
|
|
@ -2422,10 +2422,8 @@ nir_shader_lower_instructions(nir_shader *shader,
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl &&
|
||||
nir_function_impl_lower_instructions(function->impl,
|
||||
filter, lower, cb_data))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (nir_function_impl_lower_instructions(impl, filter, lower, cb_data))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1194,11 +1194,8 @@ ${pass_name}(nir_shader *shader)
|
|||
condition_flags[${index}] = ${condition};
|
||||
% endfor
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
progress |= nir_algebraic_impl(function->impl, condition_flags,
|
||||
&${pass_name}_table);
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_algebraic_impl(impl, condition_flags, &${pass_name}_table);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -83,24 +83,21 @@ nir_shader_instructions_pass(nir_shader *shader,
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
bool func_progress = false;
|
||||
nir_builder b = nir_builder_create(function->impl);
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
|
||||
nir_foreach_block_safe(block, function->impl) {
|
||||
nir_foreach_block_safe(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
func_progress |= pass(&b, instr, cb_data);
|
||||
}
|
||||
}
|
||||
|
||||
if (func_progress) {
|
||||
nir_metadata_preserve(function->impl, preserved);
|
||||
nir_metadata_preserve(impl, preserved);
|
||||
progress = true;
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -406,8 +406,8 @@ bool
|
|||
nir_remove_dead_derefs(nir_shader *shader)
|
||||
{
|
||||
bool progress = false;
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl && nir_remove_dead_derefs_impl(function->impl))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (nir_remove_dead_derefs_impl(impl))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
@ -417,11 +417,8 @@ nir_remove_dead_derefs(nir_shader *shader)
|
|||
void
|
||||
nir_fixup_deref_modes(nir_shader *shader)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
if (instr->type != nir_instr_type_deref)
|
||||
continue;
|
||||
|
|
@ -1517,8 +1514,8 @@ nir_opt_deref(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(func, shader) {
|
||||
if (func->impl && nir_opt_deref_impl(func->impl))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (nir_opt_deref_impl(impl))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -200,9 +200,8 @@ nir_calc_dominance_impl(nir_function_impl *impl)
|
|||
void
|
||||
nir_calc_dominance(nir_shader *shader)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
nir_calc_dominance_impl(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_calc_dominance_impl(impl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -293,9 +292,8 @@ nir_dump_dom_tree_impl(nir_function_impl *impl, FILE *fp)
|
|||
void
|
||||
nir_dump_dom_tree(nir_shader *shader, FILE *fp)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
nir_dump_dom_tree_impl(function->impl, fp);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_dump_dom_tree_impl(impl, fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -315,9 +313,8 @@ nir_dump_dom_frontier_impl(nir_function_impl *impl, FILE *fp)
|
|||
void
|
||||
nir_dump_dom_frontier(nir_shader *shader, FILE *fp)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
nir_dump_dom_frontier_impl(function->impl, fp);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_dump_dom_frontier_impl(impl, fp);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -339,8 +336,7 @@ nir_dump_cfg_impl(nir_function_impl *impl, FILE *fp)
|
|||
void
|
||||
nir_dump_cfg(nir_shader *shader, FILE *fp)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
nir_dump_cfg_impl(function->impl, fp);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_dump_cfg_impl(impl, fp);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -910,9 +910,8 @@ nir_convert_from_ssa(nir_shader *shader, bool phi_webs_only)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress |= nir_convert_from_ssa_impl(function->impl, phi_webs_only);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_convert_from_ssa_impl(impl, phi_webs_only);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -1023,10 +1023,8 @@ nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
|
|||
|
||||
shader->info.ray_queries += MAX2(glsl_get_aoa_size(var->type), 1);
|
||||
}
|
||||
nir_foreach_function(func, shader) {
|
||||
if (!func->impl)
|
||||
continue;
|
||||
nir_foreach_function_temp_variable(var, func->impl) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_function_temp_variable(var, impl) {
|
||||
if (!var->data.ray_query)
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -475,16 +475,13 @@ void
|
|||
nir_group_loads(nir_shader *shader, nir_load_grouping grouping,
|
||||
unsigned max_distance)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_foreach_block(block, function->impl) {
|
||||
process_block(block, grouping, max_distance);
|
||||
}
|
||||
|
||||
nir_metadata_preserve(function->impl,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance |
|
||||
nir_metadata_loop_analysis);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
process_block(block, grouping, max_distance);
|
||||
}
|
||||
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance |
|
||||
nir_metadata_loop_analysis);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,14 +64,11 @@ nir_gs_count_vertices_and_primitives(const nir_shader *shader,
|
|||
int prmcnt_arr[4] = {-1, -1, -1, -1};
|
||||
bool cnt_found[4] = {false, false, false, false};
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
/* set_vertex_and_primitive_count intrinsics only appear in predecessors of the
|
||||
* end block. So we don't need to walk all of them.
|
||||
*/
|
||||
set_foreach(function->impl->end_block->predecessors, entry) {
|
||||
set_foreach(impl->end_block->predecessors, entry) {
|
||||
nir_block *block = (nir_block *) entry->key;
|
||||
|
||||
nir_foreach_instr_reverse(instr, block) {
|
||||
|
|
|
|||
|
|
@ -275,9 +275,8 @@ nir_inline_functions(nir_shader *shader)
|
|||
struct set *inlined = _mesa_pointer_set_create(NULL);
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress = inline_function_impl(function->impl, inlined) || progress;
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress = inline_function_impl(impl, inlined) || progress;
|
||||
}
|
||||
|
||||
_mesa_set_destroy(inlined, NULL);
|
||||
|
|
|
|||
|
|
@ -369,14 +369,12 @@ nir_find_inlinable_uniforms(nir_shader *shader)
|
|||
uint32_t uni_offsets[MAX_INLINABLE_UNIFORMS];
|
||||
uint8_t num_offsets = 0;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_metadata_require(function->impl, nir_metadata_loop_analysis,
|
||||
nir_var_all, false);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_metadata_require(impl, nir_metadata_loop_analysis,
|
||||
nir_var_all, false);
|
||||
|
||||
foreach_list_typed(nir_cf_node, node, node, &function->impl->body)
|
||||
process_node(node, NULL, uni_offsets, &num_offsets);
|
||||
}
|
||||
foreach_list_typed(nir_cf_node, node, node, &impl->body)
|
||||
process_node(node, NULL, uni_offsets, &num_offsets);
|
||||
}
|
||||
|
||||
for (int i = 0; i < num_offsets; i++)
|
||||
|
|
@ -392,86 +390,84 @@ nir_inline_uniforms(nir_shader *shader, unsigned num_uniforms,
|
|||
if (!num_uniforms)
|
||||
return;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_builder b = nir_builder_create(function->impl);
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
||||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||
|
||||
/* Only replace UBO 0 with constant offsets. */
|
||||
if (intr->intrinsic == nir_intrinsic_load_ubo &&
|
||||
nir_src_is_const(intr->src[0]) &&
|
||||
nir_src_as_uint(intr->src[0]) == 0 &&
|
||||
nir_src_is_const(intr->src[1]) &&
|
||||
/* TODO: Can't handle other bit sizes for now. */
|
||||
intr->dest.ssa.bit_size == 32) {
|
||||
int num_components = intr->dest.ssa.num_components;
|
||||
uint32_t offset = nir_src_as_uint(intr->src[1]) / 4;
|
||||
/* Only replace UBO 0 with constant offsets. */
|
||||
if (intr->intrinsic == nir_intrinsic_load_ubo &&
|
||||
nir_src_is_const(intr->src[0]) &&
|
||||
nir_src_as_uint(intr->src[0]) == 0 &&
|
||||
nir_src_is_const(intr->src[1]) &&
|
||||
/* TODO: Can't handle other bit sizes for now. */
|
||||
intr->dest.ssa.bit_size == 32) {
|
||||
int num_components = intr->dest.ssa.num_components;
|
||||
uint32_t offset = nir_src_as_uint(intr->src[1]) / 4;
|
||||
|
||||
if (num_components == 1) {
|
||||
/* Just replace the uniform load to constant load. */
|
||||
for (unsigned i = 0; i < num_uniforms; i++) {
|
||||
if (offset == uniform_dw_offsets[i]) {
|
||||
b.cursor = nir_before_instr(&intr->instr);
|
||||
nir_ssa_def *def = nir_imm_int(&b, uniform_values[i]);
|
||||
nir_ssa_def_rewrite_uses(&intr->dest.ssa, def);
|
||||
nir_instr_remove(&intr->instr);
|
||||
break;
|
||||
}
|
||||
if (num_components == 1) {
|
||||
/* Just replace the uniform load to constant load. */
|
||||
for (unsigned i = 0; i < num_uniforms; i++) {
|
||||
if (offset == uniform_dw_offsets[i]) {
|
||||
b.cursor = nir_before_instr(&intr->instr);
|
||||
nir_ssa_def *def = nir_imm_int(&b, uniform_values[i]);
|
||||
nir_ssa_def_rewrite_uses(&intr->dest.ssa, def);
|
||||
nir_instr_remove(&intr->instr);
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* Lower vector uniform load to scalar and replace each
|
||||
* found component load with constant load.
|
||||
*/
|
||||
uint32_t max_offset = offset + num_components;
|
||||
nir_ssa_def *components[NIR_MAX_VEC_COMPONENTS] = {0};
|
||||
bool found = false;
|
||||
|
||||
b.cursor = nir_before_instr(&intr->instr);
|
||||
|
||||
/* Find component to replace. */
|
||||
for (unsigned i = 0; i < num_uniforms; i++) {
|
||||
uint32_t uni_offset = uniform_dw_offsets[i];
|
||||
if (uni_offset >= offset && uni_offset < max_offset) {
|
||||
int index = uni_offset - offset;
|
||||
components[index] = nir_imm_int(&b, uniform_values[i]);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
continue;
|
||||
|
||||
/* Create per-component uniform load. */
|
||||
for (unsigned i = 0; i < num_components; i++) {
|
||||
if (!components[i]) {
|
||||
uint32_t scalar_offset = (offset + i) * 4;
|
||||
components[i] = nir_load_ubo(&b, 1, intr->dest.ssa.bit_size,
|
||||
intr->src[0].ssa,
|
||||
nir_imm_int(&b, scalar_offset));
|
||||
nir_intrinsic_instr *load =
|
||||
nir_instr_as_intrinsic(components[i]->parent_instr);
|
||||
nir_intrinsic_set_align(load, NIR_ALIGN_MUL_MAX, scalar_offset);
|
||||
nir_intrinsic_set_range_base(load, scalar_offset);
|
||||
nir_intrinsic_set_range(load, 4);
|
||||
}
|
||||
}
|
||||
|
||||
/* Replace the original uniform load. */
|
||||
nir_ssa_def_rewrite_uses(&intr->dest.ssa,
|
||||
nir_vec(&b, components, num_components));
|
||||
nir_instr_remove(&intr->instr);
|
||||
}
|
||||
} else {
|
||||
/* Lower vector uniform load to scalar and replace each
|
||||
* found component load with constant load.
|
||||
*/
|
||||
uint32_t max_offset = offset + num_components;
|
||||
nir_ssa_def *components[NIR_MAX_VEC_COMPONENTS] = {0};
|
||||
bool found = false;
|
||||
|
||||
b.cursor = nir_before_instr(&intr->instr);
|
||||
|
||||
/* Find component to replace. */
|
||||
for (unsigned i = 0; i < num_uniforms; i++) {
|
||||
uint32_t uni_offset = uniform_dw_offsets[i];
|
||||
if (uni_offset >= offset && uni_offset < max_offset) {
|
||||
int index = uni_offset - offset;
|
||||
components[index] = nir_imm_int(&b, uniform_values[i]);
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
continue;
|
||||
|
||||
/* Create per-component uniform load. */
|
||||
for (unsigned i = 0; i < num_components; i++) {
|
||||
if (!components[i]) {
|
||||
uint32_t scalar_offset = (offset + i) * 4;
|
||||
components[i] = nir_load_ubo(&b, 1, intr->dest.ssa.bit_size,
|
||||
intr->src[0].ssa,
|
||||
nir_imm_int(&b, scalar_offset));
|
||||
nir_intrinsic_instr *load =
|
||||
nir_instr_as_intrinsic(components[i]->parent_instr);
|
||||
nir_intrinsic_set_align(load, NIR_ALIGN_MUL_MAX, scalar_offset);
|
||||
nir_intrinsic_set_range_base(load, scalar_offset);
|
||||
nir_intrinsic_set_range(load, 4);
|
||||
}
|
||||
}
|
||||
|
||||
/* Replace the original uniform load. */
|
||||
nir_ssa_def_rewrite_uses(&intr->dest.ssa,
|
||||
nir_vec(&b, components, num_components));
|
||||
nir_instr_remove(&intr->instr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,11 +80,8 @@ get_num_components(nir_variable *var)
|
|||
static void
|
||||
tcs_add_output_reads(nir_shader *shader, uint64_t *read, uint64_t *patches_read)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -43,8 +43,7 @@ nir_lower_alpha_test(nir_shader *shader, enum compare_func func,
|
|||
assert(alpha_ref_state_tokens);
|
||||
assert(shader->info.stage == MESA_SHADER_FRAGMENT);
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
nir_function_impl *impl = function->impl;
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
b.cursor = nir_before_cf_list(&impl->body);
|
||||
|
||||
|
|
|
|||
|
|
@ -236,11 +236,7 @@ nir_lower_amul(nir_shader *shader,
|
|||
}
|
||||
|
||||
/* clear pass flags: */
|
||||
nir_foreach_function(function, shader) {
|
||||
nir_function_impl *impl = function->impl;
|
||||
if (!impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
instr->pass_flags = 0;
|
||||
|
|
@ -248,12 +244,7 @@ nir_lower_amul(nir_shader *shader,
|
|||
}
|
||||
}
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
nir_function_impl *impl = function->impl;
|
||||
|
||||
if (!impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
lower_instr(&state, instr);
|
||||
|
|
@ -268,12 +259,7 @@ nir_lower_amul(nir_shader *shader,
|
|||
* Note the exception for 64b (such as load/store_global where
|
||||
* address size is 64b) as imul24 cannot have 64b bitsize
|
||||
*/
|
||||
nir_foreach_function(function, shader) {
|
||||
nir_function_impl *impl = function->impl;
|
||||
|
||||
if (!impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
if (instr->type != nir_instr_type_alu)
|
||||
|
|
|
|||
|
|
@ -186,9 +186,8 @@ nir_lower_array_deref_of_vec(nir_shader *shader, nir_variable_mode modes,
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl &&
|
||||
nir_lower_array_deref_of_vec_impl(function->impl, modes, options))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (nir_lower_array_deref_of_vec_impl(impl, modes, options))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -186,20 +186,18 @@ nir_lower_atomics_to_ssbo(nir_shader *shader, unsigned offset_align_state)
|
|||
unsigned ssbo_offset = shader->info.num_ssbos;
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_builder builder = nir_builder_create(function->impl);
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type == nir_instr_type_intrinsic)
|
||||
progress |= lower_instr(nir_instr_as_intrinsic(instr),
|
||||
ssbo_offset, &builder, offset_align_state);
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_builder builder = nir_builder_create(impl);
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type == nir_instr_type_intrinsic)
|
||||
progress |= lower_instr(nir_instr_as_intrinsic(instr),
|
||||
ssbo_offset, &builder, offset_align_state);
|
||||
}
|
||||
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
}
|
||||
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
|
|
|
|||
|
|
@ -293,9 +293,8 @@ nir_lower_bit_size(nir_shader *shader,
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress |= lower_impl(function->impl, callback, callback_data);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= lower_impl(impl, callback, callback_data);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -169,22 +169,20 @@ static nir_ssa_def *
|
|||
find_output(nir_shader *shader, unsigned drvloc)
|
||||
{
|
||||
nir_ssa_def *def = NULL;
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_foreach_block_reverse(block, function->impl) {
|
||||
nir_ssa_def *new_def = find_output_in_block(block, drvloc);
|
||||
assert(!(new_def && def));
|
||||
def = new_def;
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block_reverse(block, impl) {
|
||||
nir_ssa_def *new_def = find_output_in_block(block, drvloc);
|
||||
assert(!(new_def && def));
|
||||
def = new_def;
|
||||
#if !defined(DEBUG)
|
||||
/* for debug builds, scan entire shader to assert
|
||||
* if output is written multiple times. For release
|
||||
* builds just assume all is well and bail when we
|
||||
* find first:
|
||||
*/
|
||||
if (def)
|
||||
break;
|
||||
/* for debug builds, scan entire shader to assert
|
||||
* if output is written multiple times. For release
|
||||
* builds just assume all is well and bail when we
|
||||
* find first:
|
||||
*/
|
||||
if (def)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,18 +139,15 @@ nir_lower_clip_cull_distance_arrays(nir_shader *nir)
|
|||
nir->info.stage == MESA_SHADER_FRAGMENT);
|
||||
}
|
||||
|
||||
nir_foreach_function(function, nir) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, nir) {
|
||||
if (progress) {
|
||||
nir_metadata_preserve(function->impl,
|
||||
nir_metadata_preserve(impl,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance |
|
||||
nir_metadata_live_ssa_defs |
|
||||
nir_metadata_loop_analysis);
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,8 +164,8 @@ nir_lower_continue_constructs(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl && lower_continue_constructs_impl(function->impl))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (lower_continue_constructs_impl(impl))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -109,8 +109,8 @@ nir_opt_simplify_convert_alu_types(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(func, shader) {
|
||||
if (func->impl && opt_simplify_convert_alu_types_impl(func->impl))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (opt_simplify_convert_alu_types_impl(impl))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
@ -158,8 +158,8 @@ nir_lower_convert_alu_types(nir_shader *shader,
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(func, shader) {
|
||||
if (func->impl && lower_convert_alu_types_impl(func->impl, should_lower))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (lower_convert_alu_types_impl(impl, should_lower))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -792,10 +792,8 @@ nir_lower_doubles(nir_shader *shader,
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
progress |= nir_lower_doubles_impl(function->impl, softfp64, options);
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_lower_doubles_impl(impl, softfp64, options);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -637,11 +637,8 @@ nir_lower_flrp(nir_shader *shader,
|
|||
if (!u_vector_init_pow2(&dead_flrp, 8, sizeof(struct nir_alu_instr *)))
|
||||
return false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
lower_flrp_impl(function->impl, &dead_flrp, lowering_mask,
|
||||
always_precise);
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
lower_flrp_impl(impl, &dead_flrp, lowering_mask, always_precise);
|
||||
}
|
||||
|
||||
/* Progress was made if the dead list is not empty. Remove all the
|
||||
|
|
|
|||
|
|
@ -72,11 +72,9 @@ nir_lower_global_vars_to_local(nir_shader *shader)
|
|||
*/
|
||||
struct hash_table *var_func_table = _mesa_pointer_hash_table_create(NULL);
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_foreach_block(block, function->impl)
|
||||
mark_global_var_uses_block(block, function->impl, var_func_table);
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl)
|
||||
mark_global_var_uses_block(block, impl, var_func_table);
|
||||
}
|
||||
|
||||
nir_foreach_variable_with_modes_safe(var, shader, nir_var_shader_temp) {
|
||||
|
|
@ -102,9 +100,8 @@ nir_lower_global_vars_to_local(nir_shader *shader)
|
|||
if (progress)
|
||||
nir_fixup_deref_modes(shader);
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -986,8 +986,8 @@ nir_lower_goto_ifs(nir_shader *shader)
|
|||
{
|
||||
bool progress = true;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl && nir_lower_goto_ifs_impl(function->impl))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (nir_lower_goto_ifs_impl(impl))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -218,11 +218,9 @@ nir_lower_indirect_derefs(nir_shader *shader, nir_variable_mode modes,
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
progress = lower_indirects_impl(function->impl, modes, NULL,
|
||||
max_lower_array_len) || progress;
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress = lower_indirects_impl(impl, modes, NULL, max_lower_array_len) ||
|
||||
progress;
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
@ -234,11 +232,9 @@ nir_lower_indirect_var_derefs(nir_shader *shader, const struct set *vars)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
progress = lower_indirects_impl(function->impl, nir_var_uniform,
|
||||
vars, UINT_MAX) || progress;
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress = lower_indirects_impl(impl, nir_var_uniform, vars, UINT_MAX) ||
|
||||
progress;
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -262,8 +262,8 @@ nir_lower_int_to_float(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl && nir_lower_int_to_float_impl(function->impl))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (nir_lower_int_to_float_impl(impl))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -755,11 +755,8 @@ nir_lower_io(nir_shader *shader, nir_variable_mode modes,
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
progress |= nir_lower_io_impl(function->impl, modes,
|
||||
type_size, options);
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_lower_io_impl(impl, modes, type_size, options);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
@ -2327,9 +2324,8 @@ nir_lower_explicit_io(nir_shader *shader, nir_variable_mode modes,
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl &&
|
||||
nir_lower_explicit_io_impl(function->impl, modes, addr_format))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (impl && nir_lower_explicit_io_impl(impl, modes, addr_format))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
@ -2513,13 +2509,11 @@ nir_lower_vars_to_explicit_types(nir_shader *shader,
|
|||
if (modes & nir_var_mem_task_payload)
|
||||
progress |= lower_vars_to_explicit(shader, &shader->variables, nir_var_mem_task_payload, type_info);
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
if (modes & nir_var_function_temp)
|
||||
progress |= lower_vars_to_explicit(shader, &function->impl->locals, nir_var_function_temp, type_info);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (modes & nir_var_function_temp)
|
||||
progress |= lower_vars_to_explicit(shader, &impl->locals, nir_var_function_temp, type_info);
|
||||
|
||||
progress |= nir_lower_vars_to_explicit_types_impl(function->impl, modes, type_info);
|
||||
}
|
||||
progress |= nir_lower_vars_to_explicit_types_impl(impl, modes, type_info);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
@ -2873,19 +2867,17 @@ nir_io_add_const_offset_to_base(nir_shader *nir, nir_variable_mode modes)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(f, nir) {
|
||||
if (f->impl) {
|
||||
bool impl_progress = false;
|
||||
nir_builder b = nir_builder_create(f->impl);
|
||||
nir_foreach_block(block, f->impl) {
|
||||
impl_progress |= add_const_offset_to_base_block(block, &b, modes);
|
||||
}
|
||||
progress |= impl_progress;
|
||||
if (impl_progress)
|
||||
nir_metadata_preserve(f->impl, nir_metadata_block_index | nir_metadata_dominance);
|
||||
else
|
||||
nir_metadata_preserve(f->impl, nir_metadata_all);
|
||||
nir_foreach_function_impl(impl, nir) {
|
||||
bool impl_progress = false;
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
nir_foreach_block(block, impl) {
|
||||
impl_progress |= add_const_offset_to_base_block(block, &b, modes);
|
||||
}
|
||||
progress |= impl_progress;
|
||||
if (impl_progress)
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index | nir_metadata_dominance);
|
||||
else
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -228,44 +228,42 @@ static void
|
|||
create_indirects_mask(nir_shader *shader,
|
||||
BITSET_WORD *indirects, nir_variable_mode mode)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_builder b = nir_builder_create(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
||||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||
|
||||
if (intr->intrinsic != nir_intrinsic_load_deref &&
|
||||
intr->intrinsic != nir_intrinsic_store_deref &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_centroid &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_sample &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_offset &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_vertex)
|
||||
continue;
|
||||
if (intr->intrinsic != nir_intrinsic_load_deref &&
|
||||
intr->intrinsic != nir_intrinsic_store_deref &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_centroid &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_sample &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_offset &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_vertex)
|
||||
continue;
|
||||
|
||||
nir_deref_instr *deref = nir_src_as_deref(intr->src[0]);
|
||||
if (!nir_deref_mode_is(deref, mode))
|
||||
continue;
|
||||
nir_deref_instr *deref = nir_src_as_deref(intr->src[0]);
|
||||
if (!nir_deref_mode_is(deref, mode))
|
||||
continue;
|
||||
|
||||
nir_variable *var = nir_deref_instr_get_variable(deref);
|
||||
nir_variable *var = nir_deref_instr_get_variable(deref);
|
||||
|
||||
nir_deref_path path;
|
||||
nir_deref_path_init(&path, deref, NULL);
|
||||
nir_deref_path path;
|
||||
nir_deref_path_init(&path, deref, NULL);
|
||||
|
||||
int loc = var->data.location * 4 + var->data.location_frac;
|
||||
if (deref_has_indirect(&b, var, &path))
|
||||
BITSET_SET(indirects, loc);
|
||||
int loc = var->data.location * 4 + var->data.location_frac;
|
||||
if (deref_has_indirect(&b, var, &path))
|
||||
BITSET_SET(indirects, loc);
|
||||
|
||||
nir_deref_path_finish(&path);
|
||||
}
|
||||
nir_deref_path_finish(&path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -274,86 +272,84 @@ lower_io_arrays_to_elements(nir_shader *shader, nir_variable_mode mask,
|
|||
struct hash_table *varyings,
|
||||
bool after_cross_stage_opts)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_builder b = nir_builder_create(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
||||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||
|
||||
if (intr->intrinsic != nir_intrinsic_load_deref &&
|
||||
intr->intrinsic != nir_intrinsic_store_deref &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_centroid &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_sample &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_offset &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_vertex)
|
||||
continue;
|
||||
if (intr->intrinsic != nir_intrinsic_load_deref &&
|
||||
intr->intrinsic != nir_intrinsic_store_deref &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_centroid &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_sample &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_offset &&
|
||||
intr->intrinsic != nir_intrinsic_interp_deref_at_vertex)
|
||||
continue;
|
||||
|
||||
nir_deref_instr *deref = nir_src_as_deref(intr->src[0]);
|
||||
if (!nir_deref_mode_is_one_of(deref, mask))
|
||||
continue;
|
||||
nir_deref_instr *deref = nir_src_as_deref(intr->src[0]);
|
||||
if (!nir_deref_mode_is_one_of(deref, mask))
|
||||
continue;
|
||||
|
||||
nir_variable *var = nir_deref_instr_get_variable(deref);
|
||||
nir_variable *var = nir_deref_instr_get_variable(deref);
|
||||
|
||||
/* Drivers assume compact arrays are, in fact, arrays. */
|
||||
if (var->data.compact)
|
||||
continue;
|
||||
/* Drivers assume compact arrays are, in fact, arrays. */
|
||||
if (var->data.compact)
|
||||
continue;
|
||||
|
||||
/* Per-view variables are expected to remain arrays. */
|
||||
if (var->data.per_view)
|
||||
continue;
|
||||
/* Per-view variables are expected to remain arrays. */
|
||||
if (var->data.per_view)
|
||||
continue;
|
||||
|
||||
/* Skip indirects */
|
||||
int loc = var->data.location * 4 + var->data.location_frac;
|
||||
if (BITSET_TEST(indirects, loc))
|
||||
continue;
|
||||
/* Skip indirects */
|
||||
int loc = var->data.location * 4 + var->data.location_frac;
|
||||
if (BITSET_TEST(indirects, loc))
|
||||
continue;
|
||||
|
||||
nir_variable_mode mode = var->data.mode;
|
||||
nir_variable_mode mode = var->data.mode;
|
||||
|
||||
const struct glsl_type *type = var->type;
|
||||
if (nir_is_arrayed_io(var, b.shader->info.stage)) {
|
||||
assert(glsl_type_is_array(type));
|
||||
type = glsl_get_array_element(type);
|
||||
}
|
||||
const struct glsl_type *type = var->type;
|
||||
if (nir_is_arrayed_io(var, b.shader->info.stage)) {
|
||||
assert(glsl_type_is_array(type));
|
||||
type = glsl_get_array_element(type);
|
||||
}
|
||||
|
||||
/* Skip types we cannot split.
|
||||
*
|
||||
* TODO: Add support for struct splitting.
|
||||
*/
|
||||
if ((!glsl_type_is_array(type) && !glsl_type_is_matrix(type))||
|
||||
glsl_type_is_struct_or_ifc(glsl_without_array(type)))
|
||||
continue;
|
||||
/* Skip types we cannot split.
|
||||
*
|
||||
* TODO: Add support for struct splitting.
|
||||
*/
|
||||
if ((!glsl_type_is_array(type) && !glsl_type_is_matrix(type))||
|
||||
glsl_type_is_struct_or_ifc(glsl_without_array(type)))
|
||||
continue;
|
||||
|
||||
/* Skip builtins */
|
||||
if (!after_cross_stage_opts &&
|
||||
var->data.location < VARYING_SLOT_VAR0 &&
|
||||
var->data.location >= 0)
|
||||
continue;
|
||||
/* Skip builtins */
|
||||
if (!after_cross_stage_opts &&
|
||||
var->data.location < VARYING_SLOT_VAR0 &&
|
||||
var->data.location >= 0)
|
||||
continue;
|
||||
|
||||
/* Don't bother splitting if we can't opt away any unused
|
||||
* elements.
|
||||
*/
|
||||
if (!after_cross_stage_opts && var->data.always_active_io)
|
||||
continue;
|
||||
/* Don't bother splitting if we can't opt away any unused
|
||||
* elements.
|
||||
*/
|
||||
if (!after_cross_stage_opts && var->data.always_active_io)
|
||||
continue;
|
||||
|
||||
switch (intr->intrinsic) {
|
||||
case nir_intrinsic_interp_deref_at_centroid:
|
||||
case nir_intrinsic_interp_deref_at_sample:
|
||||
case nir_intrinsic_interp_deref_at_offset:
|
||||
case nir_intrinsic_interp_deref_at_vertex:
|
||||
case nir_intrinsic_load_deref:
|
||||
case nir_intrinsic_store_deref:
|
||||
if ((mask & nir_var_shader_in && mode == nir_var_shader_in) ||
|
||||
(mask & nir_var_shader_out && mode == nir_var_shader_out))
|
||||
lower_array(&b, intr, var, varyings);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (intr->intrinsic) {
|
||||
case nir_intrinsic_interp_deref_at_centroid:
|
||||
case nir_intrinsic_interp_deref_at_sample:
|
||||
case nir_intrinsic_interp_deref_at_offset:
|
||||
case nir_intrinsic_interp_deref_at_vertex:
|
||||
case nir_intrinsic_load_deref:
|
||||
case nir_intrinsic_store_deref:
|
||||
if ((mask & nir_var_shader_in && mode == nir_var_shader_in) ||
|
||||
(mask & nir_var_shader_out && mode == nir_var_shader_out))
|
||||
lower_array(&b, intr, var, varyings);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -361,18 +361,15 @@ nir_lower_io_to_temporaries(nir_shader *shader, nir_function_impl *entrypoint,
|
|||
_mesa_hash_table_insert(state.input_map, var, input);
|
||||
}
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl == NULL)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (inputs)
|
||||
emit_input_copies_impl(&state, function->impl);
|
||||
emit_input_copies_impl(&state, impl);
|
||||
|
||||
if (outputs)
|
||||
emit_output_copies_impl(&state, function->impl);
|
||||
emit_output_copies_impl(&state, impl);
|
||||
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
}
|
||||
|
||||
exec_list_append(&shader->variables, &state.old_inputs);
|
||||
|
|
|
|||
|
|
@ -614,9 +614,8 @@ nir_lower_io_to_vector(nir_shader *shader, nir_variable_mode modes)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress |= nir_lower_io_to_vector_impl(function->impl, modes);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_lower_io_to_vector_impl(impl, modes);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
@ -718,9 +717,8 @@ nir_vectorize_tess_levels(nir_shader *shader)
|
|||
}
|
||||
}
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress |= nir_vectorize_tess_levels_impl(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_vectorize_tess_levels_impl(impl);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -76,11 +76,8 @@ nir_lower_load_and_store_is_helper(nir_builder *b, nir_instr *instr, void *data)
|
|||
static bool
|
||||
has_is_helper_invocation(nir_shader *shader)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_block_safe(block, function->impl) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block_safe(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -91,9 +91,8 @@ nir_lower_load_const_to_scalar(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress |= nir_lower_load_const_to_scalar_impl(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_lower_load_const_to_scalar_impl(impl);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -322,12 +322,8 @@ nir_lower_locals_to_regs(nir_shader *shader, uint8_t bool_bitsize)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
progress =
|
||||
nir_lower_locals_to_regs_impl(function->impl, bool_bitsize) ||
|
||||
progress;
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress = nir_lower_locals_to_regs_impl(impl, bool_bitsize) || progress;
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -589,8 +589,8 @@ nir_lower_mediump_vars(nir_shader *shader, nir_variable_mode modes)
|
|||
ralloc_free(no_lower_set);
|
||||
}
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl && nir_lower_mediump_vars_impl(function->impl, modes, progress))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (nir_lower_mediump_vars_impl(impl, modes, progress))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -188,8 +188,8 @@ nir_lower_memcpy(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl && lower_memcpy_impl(function->impl))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (lower_memcpy_impl(impl))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -328,9 +328,8 @@ nir_lower_non_uniform_access(nir_shader *shader,
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl &&
|
||||
nir_lower_non_uniform_access_impl(function->impl, options))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (nir_lower_non_uniform_access_impl(impl, options))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,40 +62,38 @@ nir_lower_patch_vertices(nir_shader *nir,
|
|||
if (static_count == 0 && !uniform_state_tokens)
|
||||
return false;
|
||||
|
||||
nir_foreach_function(function, nir) {
|
||||
if (function->impl) {
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_builder b = nir_builder_create(function->impl);
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type == nir_instr_type_intrinsic) {
|
||||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||
if (intr->intrinsic != nir_intrinsic_load_patch_vertices_in)
|
||||
continue;
|
||||
nir_foreach_function_impl(impl, nir) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type == nir_instr_type_intrinsic) {
|
||||
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
||||
if (intr->intrinsic != nir_intrinsic_load_patch_vertices_in)
|
||||
continue;
|
||||
|
||||
b.cursor = nir_before_instr(&intr->instr);
|
||||
b.cursor = nir_before_instr(&intr->instr);
|
||||
|
||||
nir_ssa_def *val = NULL;
|
||||
if (static_count) {
|
||||
val = nir_imm_int(&b, static_count);
|
||||
} else {
|
||||
if (!var)
|
||||
var = make_uniform(nir, uniform_state_tokens);
|
||||
nir_ssa_def *val = NULL;
|
||||
if (static_count) {
|
||||
val = nir_imm_int(&b, static_count);
|
||||
} else {
|
||||
if (!var)
|
||||
var = make_uniform(nir, uniform_state_tokens);
|
||||
|
||||
val = nir_load_var(&b, var);
|
||||
}
|
||||
|
||||
progress = true;
|
||||
nir_ssa_def_rewrite_uses(&intr->dest.ssa,
|
||||
val);
|
||||
nir_instr_remove(instr);
|
||||
val = nir_load_var(&b, var);
|
||||
}
|
||||
|
||||
progress = true;
|
||||
nir_ssa_def_rewrite_uses(&intr->dest.ssa,
|
||||
val);
|
||||
nir_instr_remove(instr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
}
|
||||
if (progress) {
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -298,9 +298,8 @@ nir_lower_phis_to_scalar(nir_shader *shader, bool lower_all)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress = lower_phis_to_scalar_impl(function->impl, lower_all) || progress;
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress = lower_phis_to_scalar_impl(impl, lower_all) || progress;
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -114,16 +114,14 @@ nir_lower_pntc_ytransform(nir_shader *shader,
|
|||
|
||||
assert(shader->info.stage == MESA_SHADER_FRAGMENT);
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
state.b = nir_builder_create(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
state.b = nir_builder_create(impl);
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
lower_pntc_ytransform_block(&state, block);
|
||||
}
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
nir_foreach_block(block, impl) {
|
||||
lower_pntc_ytransform_block(&state, block);
|
||||
}
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
}
|
||||
|
||||
return state.pntc_transform != NULL;
|
||||
|
|
|
|||
|
|
@ -300,9 +300,8 @@ nir_lower_regs_to_ssa(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress |= nir_lower_regs_to_ssa_impl(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_lower_regs_to_ssa_impl(impl);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -304,9 +304,8 @@ nir_lower_returns(nir_shader *shader)
|
|||
*/
|
||||
bool progress = nir_opt_remove_phis(shader);
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress |= nir_lower_returns_impl(function->impl) || progress;
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_lower_returns_impl(impl) || progress;
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -102,8 +102,8 @@ nir_lower_vars_to_scratch(nir_shader *shader,
|
|||
/* First, we walk the instructions and flag any variables we want to lower
|
||||
* by removing them from their respective list and setting the mode to 0.
|
||||
*/
|
||||
nir_foreach_function(function, shader) {
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
|
@ -145,8 +145,8 @@ nir_lower_vars_to_scratch(nir_shader *shader,
|
|||
return false;
|
||||
}
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
if (instr->type != nir_instr_type_deref)
|
||||
continue;
|
||||
|
|
@ -179,14 +179,11 @@ nir_lower_vars_to_scratch(nir_shader *shader,
|
|||
}
|
||||
|
||||
bool progress = false;
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_builder build = nir_builder_create(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_builder build = nir_builder_create(impl);
|
||||
|
||||
bool impl_progress = false;
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
|
@ -216,10 +213,10 @@ nir_lower_vars_to_scratch(nir_shader *shader,
|
|||
|
||||
if (impl_progress) {
|
||||
progress = true;
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1804,15 +1804,12 @@ nir_opt_stack_loads(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(func, shader) {
|
||||
if (!func->impl)
|
||||
continue;
|
||||
|
||||
nir_metadata_require(func->impl, nir_metadata_dominance |
|
||||
nir_metadata_block_index);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_metadata_require(impl, nir_metadata_dominance |
|
||||
nir_metadata_block_index);
|
||||
|
||||
bool func_progress = false;
|
||||
nir_foreach_block_safe(block, func->impl) {
|
||||
nir_foreach_block_safe(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
|
@ -1822,7 +1819,7 @@ nir_opt_stack_loads(nir_shader *shader)
|
|||
continue;
|
||||
|
||||
nir_ssa_def *value = &intrin->dest.ssa;
|
||||
nir_block *new_block = find_last_dominant_use_block(func->impl, value);
|
||||
nir_block *new_block = find_last_dominant_use_block(impl, value);
|
||||
if (new_block == block)
|
||||
continue;
|
||||
|
||||
|
|
@ -1834,7 +1831,7 @@ nir_opt_stack_loads(nir_shader *shader)
|
|||
}
|
||||
}
|
||||
|
||||
nir_metadata_preserve(func->impl,
|
||||
nir_metadata_preserve(impl,
|
||||
func_progress ? (nir_metadata_block_index |
|
||||
nir_metadata_dominance |
|
||||
nir_metadata_loop_analysis) :
|
||||
|
|
|
|||
|
|
@ -156,8 +156,7 @@ nir_lower_ssbo(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
nir_function_impl *impl = function->impl;
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
|
||||
nir_foreach_block(block, impl) {
|
||||
|
|
|
|||
|
|
@ -365,11 +365,8 @@ lower_task_intrin(nir_builder *b,
|
|||
static bool
|
||||
requires_payload_in_shared(nir_shader *shader, bool atomics, bool small_types)
|
||||
{
|
||||
nir_foreach_function(func, shader) {
|
||||
if (!func->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_block(block, func->impl) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
|
|
|||
|
|
@ -1647,9 +1647,8 @@ nir_lower_tex(nir_shader *shader, const nir_lower_tex_options *options)
|
|||
progress = nir_lower_tex(shader, &_options);
|
||||
}
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress |= nir_lower_tex_impl(function->impl, options, shader->options);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_lower_tex_impl(impl, options, shader->options);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -135,9 +135,8 @@ nir_lower_texcoord_replace(nir_shader *s, unsigned coord_replace,
|
|||
assert(s->info.stage == MESA_SHADER_FRAGMENT);
|
||||
assert(coord_replace != 0);
|
||||
|
||||
nir_foreach_function(function, s) {
|
||||
if (function->impl)
|
||||
nir_lower_texcoord_replace_impl(function->impl, coord_replace,
|
||||
point_coord_is_sysval, yinvert);
|
||||
nir_foreach_function_impl(impl, s) {
|
||||
nir_lower_texcoord_replace_impl(impl, coord_replace,
|
||||
point_coord_is_sysval, yinvert);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,15 +102,11 @@ nir_lower_variable_initializers(nir_shader *shader, nir_variable_mode modes)
|
|||
nir_var_function_temp |
|
||||
nir_var_system_value;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
bool impl_progress = false;
|
||||
nir_builder builder = nir_builder_create(impl);
|
||||
|
||||
nir_builder builder = nir_builder_create(function->impl);
|
||||
|
||||
if ((modes & ~nir_var_function_temp) && function->is_entrypoint) {
|
||||
if ((modes & ~nir_var_function_temp) && impl->function->is_entrypoint) {
|
||||
impl_progress |= lower_const_initializer(&builder,
|
||||
&shader->variables,
|
||||
modes);
|
||||
|
|
@ -118,17 +114,17 @@ nir_lower_variable_initializers(nir_shader *shader, nir_variable_mode modes)
|
|||
|
||||
if (modes & nir_var_function_temp) {
|
||||
impl_progress |= lower_const_initializer(&builder,
|
||||
&function->impl->locals,
|
||||
&impl->locals,
|
||||
nir_var_function_temp);
|
||||
}
|
||||
|
||||
if (impl_progress) {
|
||||
progress = true;
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance |
|
||||
nir_metadata_live_ssa_defs);
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -818,9 +818,8 @@ nir_lower_vars_to_ssa(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress |= nir_lower_vars_to_ssa_impl(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_lower_vars_to_ssa_impl(impl);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -134,11 +134,8 @@ nir_lower_vec3_to_vec4(nir_shader *shader, nir_variable_mode modes)
|
|||
}
|
||||
|
||||
if (modes & nir_var_function_temp) {
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_temp_variable(var, function->impl) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_function_temp_variable(var, impl) {
|
||||
const struct glsl_type *vec4_type =
|
||||
glsl_type_replace_vec3_with_vec4(var->type);
|
||||
if (var->type != vec4_type) {
|
||||
|
|
|
|||
|
|
@ -67,9 +67,8 @@ nir_metadata_preserve(nir_function_impl *impl, nir_metadata preserved)
|
|||
void
|
||||
nir_shader_preserve_all_metadata(nir_shader *shader)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -83,10 +82,8 @@ nir_shader_preserve_all_metadata(nir_shader *shader)
|
|||
void
|
||||
nir_metadata_set_validation_flag(nir_shader *shader)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
function->impl->valid_metadata |= nir_metadata_not_properly_reset;
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
impl->valid_metadata |= nir_metadata_not_properly_reset;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -100,11 +97,8 @@ nir_metadata_set_validation_flag(nir_shader *shader)
|
|||
void
|
||||
nir_metadata_check_validation_flag(nir_shader *shader)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
assert(!(function->impl->valid_metadata &
|
||||
nir_metadata_not_properly_reset));
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
assert(!(impl->valid_metadata & nir_metadata_not_properly_reset));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -199,10 +199,8 @@ nir_move_vec_src_uses_to_dest(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress |= nir_move_vec_src_uses_to_dest_impl(shader,
|
||||
function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_move_vec_src_uses_to_dest_impl(shader, impl);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -299,13 +299,11 @@ nir_opt_access(nir_shader *shader, const nir_opt_access_options *options)
|
|||
bool var_progress = false;
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(func, shader) {
|
||||
if (func->impl) {
|
||||
nir_foreach_block(block, func->impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
if (instr->type == nir_instr_type_intrinsic)
|
||||
gather_intrinsic(&state, nir_instr_as_intrinsic(instr));
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
if (instr->type == nir_instr_type_intrinsic)
|
||||
gather_intrinsic(&state, nir_instr_as_intrinsic(instr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -324,18 +322,16 @@ nir_opt_access(nir_shader *shader, const nir_opt_access_options *options)
|
|||
nir_var_image)
|
||||
var_progress |= process_variable(&state, var);
|
||||
|
||||
nir_foreach_function(func, shader) {
|
||||
if (func->impl) {
|
||||
progress |= opt_access_impl(&state, func->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= opt_access_impl(&state, impl);
|
||||
|
||||
/* If we make a change to the uniforms, update all the impls. */
|
||||
if (var_progress) {
|
||||
nir_metadata_preserve(func->impl,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance |
|
||||
nir_metadata_live_ssa_defs |
|
||||
nir_metadata_loop_analysis);
|
||||
}
|
||||
/* If we make a change to the uniforms, update all the impls. */
|
||||
if (var_progress) {
|
||||
nir_metadata_preserve(impl,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance |
|
||||
nir_metadata_live_ssa_defs |
|
||||
nir_metadata_loop_analysis);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,9 +89,8 @@ nir_opt_combine_barriers(
|
|||
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl &&
|
||||
nir_opt_combine_barriers_impl(function->impl, combine_cb, data)) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (nir_opt_combine_barriers_impl(impl, combine_cb, data)) {
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -429,10 +429,8 @@ nir_opt_combine_stores(nir_shader *shader, nir_variable_mode modes)
|
|||
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
progress |= combine_stores_impl(&state, function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= combine_stores_impl(&state, impl);
|
||||
}
|
||||
|
||||
ralloc_free(mem_ctx);
|
||||
|
|
|
|||
|
|
@ -403,9 +403,8 @@ nir_opt_comparison_pre(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress |= nir_opt_comparison_pre_impl(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_opt_comparison_pre_impl(impl);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -122,22 +122,20 @@ nir_opt_conditional_discard(nir_shader *shader)
|
|||
|
||||
nir_builder builder;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
builder = nir_builder_create(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
builder = nir_builder_create(impl);
|
||||
|
||||
bool impl_progress = false;
|
||||
nir_foreach_block_safe(block, function->impl) {
|
||||
if (nir_opt_conditional_discard_block(&builder, block))
|
||||
impl_progress = true;
|
||||
}
|
||||
bool impl_progress = false;
|
||||
nir_foreach_block_safe(block, impl) {
|
||||
if (nir_opt_conditional_discard_block(&builder, block))
|
||||
impl_progress = true;
|
||||
}
|
||||
|
||||
if (impl_progress) {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_none);
|
||||
progress = true;
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
}
|
||||
if (impl_progress) {
|
||||
nir_metadata_preserve(impl, nir_metadata_none);
|
||||
progress = true;
|
||||
} else {
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -1474,10 +1474,8 @@ nir_opt_copy_prop_vars(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
progress |= nir_copy_prop_vars_impl(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_copy_prop_vars_impl(impl);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -173,8 +173,8 @@ nir_copy_prop(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl && nir_copy_prop_impl(function->impl))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (nir_copy_prop_impl(impl))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -64,9 +64,8 @@ nir_opt_cse(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress |= nir_opt_cse_impl(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_opt_cse_impl(impl);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -251,8 +251,8 @@ bool
|
|||
nir_opt_dce(nir_shader *shader)
|
||||
{
|
||||
bool progress = false;
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl && nir_opt_dce_impl(function->impl))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (nir_opt_dce_impl(impl))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -421,9 +421,8 @@ nir_opt_dead_cf(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader)
|
||||
if (function->impl)
|
||||
progress |= opt_dead_cf_impl(function->impl);
|
||||
nir_foreach_function_impl(impl, shader)
|
||||
progress |= opt_dead_cf_impl(impl);
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -251,10 +251,8 @@ nir_opt_dead_write_vars(nir_shader *shader)
|
|||
void *mem_ctx = ralloc_context(NULL);
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
progress |= remove_dead_write_vars_impl(mem_ctx, shader, function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= remove_dead_write_vars_impl(mem_ctx, shader, impl);
|
||||
}
|
||||
|
||||
ralloc_free(mem_ctx);
|
||||
|
|
|
|||
|
|
@ -675,8 +675,8 @@ nir_opt_find_array_copies(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl && opt_find_array_copies_impl(function->impl))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (opt_find_array_copies_impl(impl))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -884,9 +884,8 @@ nir_opt_gcm(nir_shader *shader, bool value_number)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress |= opt_gcm_impl(shader, function->impl, value_number);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= opt_gcm_impl(shader, impl, value_number);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -1676,26 +1676,23 @@ nir_opt_if(nir_shader *shader, nir_opt_if_options options)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl == NULL)
|
||||
continue;
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
|
||||
nir_builder b = nir_builder_create(function->impl);
|
||||
|
||||
nir_metadata_require(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
progress = opt_if_safe_cf_list(&b, &function->impl->body);
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
nir_metadata_require(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
progress = opt_if_safe_cf_list(&b, &impl->body);
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
|
||||
bool preserve = true;
|
||||
|
||||
if (opt_if_cf_list(&b, &function->impl->body, options)) {
|
||||
if (opt_if_cf_list(&b, &impl->body, options)) {
|
||||
preserve = false;
|
||||
progress = true;
|
||||
}
|
||||
|
||||
if (opt_if_regs_cf_list(&function->impl->body)) {
|
||||
if (opt_if_regs_cf_list(&impl->body)) {
|
||||
preserve = false;
|
||||
progress = true;
|
||||
|
||||
|
|
@ -1703,13 +1700,13 @@ nir_opt_if(nir_shader *shader, nir_opt_if_options options)
|
|||
* need to convert registers back into SSA defs and clean up SSA defs
|
||||
* that don't dominate their uses.
|
||||
*/
|
||||
nir_lower_regs_to_ssa_impl(function->impl);
|
||||
nir_lower_regs_to_ssa_impl(impl);
|
||||
}
|
||||
|
||||
if (preserve) {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_none);
|
||||
nir_metadata_preserve(impl, nir_metadata_none);
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -340,16 +340,13 @@ nir_opt_intrinsics(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
if (opt_intrinsics_impl(function->impl, shader->options)) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (opt_intrinsics_impl(impl, shader->options)) {
|
||||
progress = true;
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1455,19 +1455,17 @@ nir_opt_load_store_vectorize(nir_shader *shader, const nir_load_store_vectorize_
|
|||
|
||||
nir_shader_index_vars(shader, options->modes);
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
if (options->modes & nir_var_function_temp)
|
||||
nir_function_impl_index_vars(function->impl);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (options->modes & nir_var_function_temp)
|
||||
nir_function_impl_index_vars(impl);
|
||||
|
||||
nir_foreach_block(block, function->impl)
|
||||
progress |= process_block(function->impl, ctx, block);
|
||||
nir_foreach_block(block, impl)
|
||||
progress |= process_block(impl, ctx, block);
|
||||
|
||||
nir_metadata_preserve(function->impl,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance |
|
||||
nir_metadata_live_ssa_defs);
|
||||
}
|
||||
nir_metadata_preserve(impl,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance |
|
||||
nir_metadata_live_ssa_defs);
|
||||
}
|
||||
|
||||
ralloc_free(ctx);
|
||||
|
|
|
|||
|
|
@ -1161,11 +1161,9 @@ nir_opt_loop_unroll(nir_shader *shader)
|
|||
|
||||
bool force_unroll_sampler_indirect = shader->options->force_indirect_unrolling_sampler;
|
||||
nir_variable_mode indirect_mask = shader->options->force_indirect_unrolling;
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
progress |= nir_opt_loop_unroll_impl(function->impl, indirect_mask,
|
||||
force_unroll_sampler_indirect);
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_opt_loop_unroll_impl(impl, indirect_mask,
|
||||
force_unroll_sampler_indirect);
|
||||
}
|
||||
return progress;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -291,8 +291,8 @@ nir_opt_memcpy(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl && opt_memcpy_impl(function->impl))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (opt_memcpy_impl(impl))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -153,23 +153,20 @@ nir_opt_move(nir_shader *shader, nir_move_options options)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(func, shader) {
|
||||
if (!func->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
bool impl_progress = false;
|
||||
nir_foreach_block(block, func->impl) {
|
||||
nir_foreach_block(block, impl) {
|
||||
if (nir_opt_move_block(block, options))
|
||||
impl_progress = true;
|
||||
}
|
||||
|
||||
if (impl_progress) {
|
||||
nir_metadata_preserve(func->impl, nir_metadata_block_index |
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance |
|
||||
nir_metadata_live_ssa_defs);
|
||||
progress = true;
|
||||
} else {
|
||||
nir_metadata_preserve(func->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -240,10 +240,10 @@ nir_opt_move_discards_to_top(nir_shader *shader)
|
|||
if (!shader->info.fs.uses_discard)
|
||||
return false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl && opt_move_discards_to_top_impl(function->impl)) {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (opt_move_discards_to_top_impl(impl)) {
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,8 +143,8 @@ nir_has_non_uniform_access_impl(nir_function_impl *impl, enum nir_lower_non_unif
|
|||
bool
|
||||
nir_has_non_uniform_access(nir_shader *shader, enum nir_lower_non_uniform_access_type types)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl && nir_has_non_uniform_access_impl(function->impl, types))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (nir_has_non_uniform_access_impl(impl, types))
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -510,11 +510,10 @@ nir_opt_peephole_select(nir_shader *shader, unsigned limit,
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress |= nir_opt_peephole_select_impl(function->impl, limit,
|
||||
indirect_load_ok,
|
||||
expensive_alu_ok);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_opt_peephole_select_impl(impl, limit,
|
||||
indirect_load_ok,
|
||||
expensive_alu_ok);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -458,23 +458,20 @@ nir_opt_phi_precision(nir_shader *shader)
|
|||
if (!(bit_sizes_used & (8 | 16)))
|
||||
return false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
|
||||
nir_builder b = nir_builder_create(function->impl);
|
||||
|
||||
nir_foreach_block (block, function->impl) {
|
||||
nir_foreach_block (block, impl) {
|
||||
nir_foreach_phi_safe (phi, block)
|
||||
progress |= lower_phi(&b, phi);
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
nir_metadata_preserve(function->impl,
|
||||
nir_metadata_preserve(impl,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -63,12 +63,7 @@ static void
|
|||
nir_find_ray_queries_read(struct set *queries,
|
||||
nir_shader *shader)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
nir_function_impl *impl = function->impl;
|
||||
|
||||
if (!impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
|
|
|
|||
|
|
@ -186,12 +186,8 @@ nir_opt_rematerialize_compares(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl == NULL)
|
||||
continue;
|
||||
|
||||
progress = nir_opt_rematerialize_compares_impl(shader, function->impl)
|
||||
|| progress;
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress = nir_opt_rematerialize_compares_impl(shader, impl) || progress;
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -170,9 +170,8 @@ nir_opt_remove_phis(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader)
|
||||
if (function->impl)
|
||||
progress = nir_opt_remove_phis_impl(function->impl) || progress;
|
||||
nir_foreach_function_impl(impl, shader)
|
||||
progress = nir_opt_remove_phis_impl(impl) || progress;
|
||||
|
||||
return progress;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,13 +100,10 @@ nir_opt_shrink_stores(nir_shader *shader, bool shrink_image_store)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
|
||||
nir_builder b = nir_builder_create(function->impl);
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
if (instr->type != nir_instr_type_intrinsic)
|
||||
continue;
|
||||
|
|
@ -116,11 +113,11 @@ nir_opt_shrink_stores(nir_shader *shader, bool shrink_image_store)
|
|||
}
|
||||
|
||||
if (progress) {
|
||||
nir_metadata_preserve(function->impl,
|
||||
nir_metadata_preserve(impl,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -479,24 +479,21 @@ nir_opt_shrink_vectors(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_builder b = nir_builder_create(impl);
|
||||
|
||||
nir_builder b = nir_builder_create(function->impl);
|
||||
|
||||
nir_foreach_block_reverse(block, function->impl) {
|
||||
nir_foreach_block_reverse(block, impl) {
|
||||
nir_foreach_instr_reverse(instr, block) {
|
||||
progress |= opt_shrink_vectors_instr(&b, instr);
|
||||
}
|
||||
}
|
||||
|
||||
if (progress) {
|
||||
nir_metadata_preserve(function->impl,
|
||||
nir_metadata_preserve(impl,
|
||||
nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -203,14 +203,11 @@ nir_opt_sink(nir_shader *shader, nir_move_options options)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_metadata_require(function->impl,
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_metadata_require(impl,
|
||||
nir_metadata_block_index | nir_metadata_dominance);
|
||||
|
||||
nir_foreach_block_reverse(block, function->impl) {
|
||||
nir_foreach_block_reverse(block, impl) {
|
||||
nir_foreach_instr_reverse_safe(instr, block) {
|
||||
if (!nir_can_move_instr(instr, options))
|
||||
continue;
|
||||
|
|
@ -233,7 +230,7 @@ nir_opt_sink(nir_shader *shader, nir_move_options options)
|
|||
}
|
||||
}
|
||||
|
||||
nir_metadata_preserve(function->impl,
|
||||
nir_metadata_preserve(impl,
|
||||
nir_metadata_block_index | nir_metadata_dominance);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -120,19 +120,16 @@ nir_opt_trivial_continues(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl == NULL)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
/* First we run the simple pass to get rid of pesky continues */
|
||||
if (lower_trivial_continues_list(&function->impl->body, false, NULL)) {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_none);
|
||||
if (lower_trivial_continues_list(&impl->body, false, NULL)) {
|
||||
nir_metadata_preserve(impl, nir_metadata_none);
|
||||
|
||||
/* If that made progress, we're no longer really in SSA form. */
|
||||
nir_lower_regs_to_ssa_impl(function->impl);
|
||||
nir_lower_regs_to_ssa_impl(impl);
|
||||
progress = true;
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -343,15 +343,12 @@ nir_opt_uniform_atomics(nir_shader *shader)
|
|||
shader->info.workgroup_size[2] == 1)
|
||||
return false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
if (opt_uniform_atomics(function->impl)) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (opt_uniform_atomics(impl)) {
|
||||
progress = true;
|
||||
nir_metadata_preserve(function->impl, nir_metadata_none);
|
||||
nir_metadata_preserve(impl, nir_metadata_none);
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -409,9 +409,8 @@ nir_opt_vectorize(nir_shader *shader, nir_vectorize_cb filter,
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress |= nir_opt_vectorize_impl(function->impl, filter, data);
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress |= nir_opt_vectorize_impl(impl, filter, data);
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -221,8 +221,8 @@ nir_propagate_invariant(nir_shader *shader, bool invariant_prim)
|
|||
}
|
||||
|
||||
bool progress = false;
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl && propagate_invariant_impl(function->impl, invariants))
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (propagate_invariant_impl(impl, invariants))
|
||||
progress = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -95,13 +95,11 @@ add_var_use_deref(nir_deref_instr *deref, struct set *live)
|
|||
static void
|
||||
add_var_use_shader(nir_shader *shader, struct set *live, nir_variable_mode modes)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
if (instr->type == nir_instr_type_deref)
|
||||
add_var_use_deref(nir_instr_as_deref(instr), live);
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
if (instr->type == nir_instr_type_deref)
|
||||
add_var_use_deref(nir_instr_as_deref(instr), live);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -110,11 +108,8 @@ add_var_use_shader(nir_shader *shader, struct set *live, nir_variable_mode modes
|
|||
static void
|
||||
remove_dead_var_writes(nir_shader *shader)
|
||||
{
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr_safe(instr, block) {
|
||||
switch (instr->type) {
|
||||
case nir_instr_type_deref: {
|
||||
|
|
@ -199,28 +194,23 @@ nir_remove_dead_variables(nir_shader *shader, nir_variable_mode modes,
|
|||
}
|
||||
|
||||
if (modes & nir_var_function_temp) {
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl) {
|
||||
if (remove_dead_vars(&function->impl->locals,
|
||||
nir_var_function_temp,
|
||||
live, opts))
|
||||
progress = true;
|
||||
}
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (remove_dead_vars(&impl->locals,
|
||||
nir_var_function_temp,
|
||||
live, opts))
|
||||
progress = true;
|
||||
}
|
||||
}
|
||||
|
||||
_mesa_set_destroy(live, NULL);
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
if (progress) {
|
||||
remove_dead_var_writes(shader);
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -184,9 +184,8 @@ nir_repair_ssa(nir_shader *shader)
|
|||
{
|
||||
bool progress = false;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl)
|
||||
progress = nir_repair_ssa_impl(function->impl) || progress;
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
progress = nir_repair_ssa_impl(impl) || progress;
|
||||
}
|
||||
|
||||
return progress;
|
||||
|
|
|
|||
|
|
@ -1107,8 +1107,8 @@ nir_schedule_get_scoreboard(nir_shader *shader,
|
|||
scoreboard->options = options;
|
||||
scoreboard->pressure = 0;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
nir_foreach_register(reg, &function->impl->registers) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_register(reg, &impl->registers) {
|
||||
struct set *register_uses =
|
||||
_mesa_pointer_set_create(scoreboard);
|
||||
|
||||
|
|
@ -1125,7 +1125,7 @@ nir_schedule_get_scoreboard(nir_shader *shader,
|
|||
}
|
||||
}
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
nir_foreach_ssa_def(instr, nir_schedule_ssa_def_init_scoreboard,
|
||||
scoreboard);
|
||||
|
|
@ -1192,11 +1192,8 @@ nir_schedule(nir_shader *shader,
|
|||
nir_print_shader(shader, stderr);
|
||||
}
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_schedule_block(scoreboard, block);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2152,9 +2152,8 @@ nir_serialize(struct blob *blob, const nir_shader *nir, bool strip)
|
|||
write_function(&ctx, fxn);
|
||||
}
|
||||
|
||||
nir_foreach_function(fxn, nir) {
|
||||
if (fxn->impl)
|
||||
write_function_impl(&ctx, fxn->impl);
|
||||
nir_foreach_function_impl(impl, nir) {
|
||||
write_function_impl(&ctx, impl);
|
||||
}
|
||||
|
||||
blob_write_uint32(blob, nir->constant_data_size);
|
||||
|
|
|
|||
|
|
@ -34,11 +34,8 @@ get_complex_used_vars(nir_shader *shader, void *mem_ctx)
|
|||
{
|
||||
struct set *complex_vars = _mesa_pointer_set_create(mem_ctx);
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_block(block, function->impl) {
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
nir_foreach_block(block, impl) {
|
||||
nir_foreach_instr(instr, block) {
|
||||
if (instr->type != nir_instr_type_deref)
|
||||
continue;
|
||||
|
|
@ -348,14 +345,11 @@ nir_split_struct_vars(nir_shader *shader, nir_variable_mode modes)
|
|||
}
|
||||
|
||||
bool progress = false;
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
bool has_local_splits = false;
|
||||
if (modes & nir_var_function_temp) {
|
||||
has_local_splits = split_var_list_structs(shader, function->impl,
|
||||
&function->impl->locals,
|
||||
has_local_splits = split_var_list_structs(shader, impl,
|
||||
&impl->locals,
|
||||
nir_var_function_temp,
|
||||
var_field_map,
|
||||
&complex_vars,
|
||||
|
|
@ -363,14 +357,14 @@ nir_split_struct_vars(nir_shader *shader, nir_variable_mode modes)
|
|||
}
|
||||
|
||||
if (has_global_splits || has_local_splits) {
|
||||
split_struct_derefs_impl(function->impl, var_field_map,
|
||||
split_struct_derefs_impl(impl, var_field_map,
|
||||
modes, mem_ctx);
|
||||
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
progress = true;
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -911,14 +905,11 @@ nir_split_array_vars(nir_shader *shader, nir_variable_mode modes)
|
|||
}
|
||||
|
||||
bool has_any_array = false;
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
bool has_local_array = false;
|
||||
if (modes & nir_var_function_temp) {
|
||||
has_local_array = init_var_list_array_infos(shader,
|
||||
&function->impl->locals,
|
||||
&impl->locals,
|
||||
nir_var_function_temp,
|
||||
var_info_map,
|
||||
&complex_vars,
|
||||
|
|
@ -927,7 +918,7 @@ nir_split_array_vars(nir_shader *shader, nir_variable_mode modes)
|
|||
|
||||
if (has_global_array || has_local_array) {
|
||||
has_any_array = true;
|
||||
mark_array_usage_impl(function->impl, var_info_map, modes, mem_ctx);
|
||||
mark_array_usage_impl(impl, var_info_map, modes, mem_ctx);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -947,27 +938,24 @@ nir_split_array_vars(nir_shader *shader, nir_variable_mode modes)
|
|||
}
|
||||
|
||||
bool progress = false;
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
bool has_local_splits = false;
|
||||
if (modes & nir_var_function_temp) {
|
||||
has_local_splits = split_var_list_arrays(shader, function->impl,
|
||||
&function->impl->locals,
|
||||
has_local_splits = split_var_list_arrays(shader, impl,
|
||||
&impl->locals,
|
||||
nir_var_function_temp,
|
||||
var_info_map, mem_ctx);
|
||||
}
|
||||
|
||||
if (has_global_splits || has_local_splits) {
|
||||
split_array_copies_impl(function->impl, var_info_map, modes, mem_ctx);
|
||||
split_array_access_impl(function->impl, var_info_map, modes, mem_ctx);
|
||||
split_array_copies_impl(impl, var_info_map, modes, mem_ctx);
|
||||
split_array_access_impl(impl, var_info_map, modes, mem_ctx);
|
||||
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
progress = true;
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1684,17 +1672,14 @@ nir_shrink_vec_array_vars(nir_shader *shader, nir_variable_mode modes)
|
|||
_mesa_pointer_hash_table_create(mem_ctx);
|
||||
|
||||
bool has_vars_to_shrink = false;
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
/* Don't even bother crawling the IR if we don't have any variables.
|
||||
* Given that this pass deletes any unused variables, it's likely that
|
||||
* we will be in this scenario eventually.
|
||||
*/
|
||||
if (function_impl_has_vars_with_modes(function->impl, modes)) {
|
||||
if (function_impl_has_vars_with_modes(impl, modes)) {
|
||||
has_vars_to_shrink = true;
|
||||
find_used_components_impl(function->impl, var_usage_map,
|
||||
find_used_components_impl(impl, var_usage_map,
|
||||
modes, mem_ctx);
|
||||
}
|
||||
}
|
||||
|
|
@ -1712,25 +1697,22 @@ nir_shrink_vec_array_vars(nir_shader *shader, nir_variable_mode modes)
|
|||
}
|
||||
|
||||
bool progress = false;
|
||||
nir_foreach_function(function, shader) {
|
||||
if (!function->impl)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
bool locals_shrunk = false;
|
||||
if (modes & nir_var_function_temp) {
|
||||
locals_shrunk = shrink_vec_var_list(&function->impl->locals,
|
||||
locals_shrunk = shrink_vec_var_list(&impl->locals,
|
||||
nir_var_function_temp,
|
||||
var_usage_map);
|
||||
}
|
||||
|
||||
if (globals_shrunk || locals_shrunk) {
|
||||
shrink_vec_var_access_impl(function->impl, var_usage_map, modes);
|
||||
shrink_vec_var_access_impl(impl, var_usage_map, modes);
|
||||
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
progress = true;
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -400,22 +400,19 @@ nir_convert_to_lcssa(nir_shader *shader, bool skip_invariants, bool skip_bool_in
|
|||
state->skip_invariants = skip_invariants;
|
||||
state->skip_bool_invariants = skip_bool_invariants;
|
||||
|
||||
nir_foreach_function(function, shader) {
|
||||
if (function->impl == NULL)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
state->progress = false;
|
||||
nir_metadata_require(function->impl, nir_metadata_block_index);
|
||||
nir_metadata_require(impl, nir_metadata_block_index);
|
||||
|
||||
foreach_list_typed(nir_cf_node, node, node, &function->impl->body)
|
||||
foreach_list_typed(nir_cf_node, node, node, &impl->body)
|
||||
convert_to_lcssa(node, state);
|
||||
|
||||
if (state->progress) {
|
||||
progress = true;
|
||||
nir_metadata_preserve(function->impl, nir_metadata_block_index |
|
||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||
nir_metadata_dominance);
|
||||
} else {
|
||||
nir_metadata_preserve(function->impl, nir_metadata_all);
|
||||
nir_metadata_preserve(impl, nir_metadata_all);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1840,18 +1840,15 @@ nir_validate_ssa_dominance(nir_shader *shader, const char *when)
|
|||
|
||||
state.shader = shader;
|
||||
|
||||
nir_foreach_function(func, shader) {
|
||||
if (func->impl == NULL)
|
||||
continue;
|
||||
|
||||
nir_foreach_function_impl(impl, shader) {
|
||||
state.ssa_defs_found = reralloc(state.mem_ctx, state.ssa_defs_found,
|
||||
BITSET_WORD,
|
||||
BITSET_WORDS(func->impl->ssa_alloc));
|
||||
memset(state.ssa_defs_found, 0, BITSET_WORDS(func->impl->ssa_alloc) *
|
||||
BITSET_WORDS(impl->ssa_alloc));
|
||||
memset(state.ssa_defs_found, 0, BITSET_WORDS(impl->ssa_alloc) *
|
||||
sizeof(BITSET_WORD));
|
||||
|
||||
state.impl = func->impl;
|
||||
validate_ssa_dominance(func->impl, &state);
|
||||
state.impl = impl;
|
||||
validate_ssa_dominance(impl, &state);
|
||||
}
|
||||
|
||||
if (_mesa_hash_table_num_entries(state.errors) > 0)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue