nir_load_const_instr_create(b->shader, rows, bit_size);
load->value = c->values[i];
nir_builder_instr_insert(b, &load->instr);
- nir_store_deref(b, nir_build_deref_array(b, deref, nir_imm_int(b, i)),
+ nir_store_deref(b, nir_build_deref_array_imm(b, deref, i),
&load->def, ~0);
}
- } else if (glsl_type_is_struct(deref->type)) {
+ } else if (glsl_type_is_struct_or_ifc(deref->type)) {
unsigned len = glsl_get_length(deref->type);
for (unsigned i = 0; i < len; i++) {
build_constant_load(b, nir_build_deref_struct(b, deref, i),
unsigned len = glsl_get_length(deref->type);
for (unsigned i = 0; i < len; i++) {
build_constant_load(b,
- nir_build_deref_array(b, deref, nir_imm_int(b, i)),
+ nir_build_deref_array_imm(b, deref, i),
c->elements[i]);
}
}
{
bool progress = false;
- nir_builder builder;
- if (modes & ~nir_var_function)
- nir_builder_init(&builder, nir_shader_get_entrypoint(shader));
+ nir_foreach_function(function, shader) {
+ if (!function->impl)
+ continue;
- if (modes & nir_var_shader_out)
- progress |= lower_const_initializer(&builder, &shader->outputs);
+ bool impl_progress = false;
- if (modes & nir_var_private)
- progress |= lower_const_initializer(&builder, &shader->globals);
+ nir_builder builder;
+ nir_builder_init(&builder, function->impl);
- if (modes & nir_var_system_value)
- progress |= lower_const_initializer(&builder, &shader->system_values);
+ if ((modes & nir_var_shader_out) && function->is_entrypoint)
+ impl_progress |= lower_const_initializer(&builder, &shader->outputs);
- if (progress) {
- nir_foreach_function(function, shader) {
- if (function->impl) {
- nir_metadata_preserve(function->impl, nir_metadata_block_index |
- nir_metadata_dominance |
- nir_metadata_live_ssa_defs);
- }
- }
- }
+ if ((modes & nir_var_shader_temp) && function->is_entrypoint)
+ impl_progress |= lower_const_initializer(&builder, &shader->globals);
+
+ if ((modes & nir_var_system_value) && function->is_entrypoint)
+ impl_progress |= lower_const_initializer(&builder, &shader->system_values);
+
+ if (modes & nir_var_function_temp)
+ impl_progress |= lower_const_initializer(&builder, &function->impl->locals);
- if (modes & nir_var_function) {
- nir_foreach_function(function, shader) {
- if (!function->impl)
- continue;
-
- nir_builder_init(&builder, function->impl);
- if (lower_const_initializer(&builder, &function->impl->locals)) {
- nir_metadata_preserve(function->impl, nir_metadata_block_index |
- nir_metadata_dominance |
- nir_metadata_live_ssa_defs);
- progress = true;
- }
+ if (impl_progress) {
+ progress = true;
+ nir_metadata_preserve(function->impl, nir_metadata_block_index |
+ nir_metadata_dominance |
+ nir_metadata_live_ssa_defs);
+ } else {
+#ifndef NDEBUG
+ function->impl->valid_metadata &= ~nir_metadata_not_properly_reset;
+#endif
}
}