summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Turner <[email protected]>2019-01-08 19:49:14 -0800
committerMatt Turner <[email protected]>2019-01-09 16:42:40 -0800
commit393b59e0772e7bf0426bdf61c740752c4e09dde1 (patch)
treef2ae3b2bce6c32c2a8a645ede5d24ba384391efb
parentf998ce41115a3c2bd87182885026a784aa6cd089 (diff)
nir: Rework nir_lower_constant_initializers() to handle functions
Previously it assumed that only a single function (the entrypoint) existed and attempted to lower constant initializers of shader outputs for each function, for instance.
-rw-r--r--src/compiler/nir/nir_lower_constant_initializers.c59
1 files changed, 25 insertions, 34 deletions
diff --git a/src/compiler/nir/nir_lower_constant_initializers.c b/src/compiler/nir/nir_lower_constant_initializers.c
index b213576bbd5..b1c51834917 100644
--- a/src/compiler/nir/nir_lower_constant_initializers.c
+++ b/src/compiler/nir/nir_lower_constant_initializers.c
@@ -91,41 +91,32 @@ nir_lower_constant_initializers(nir_shader *shader, nir_variable_mode modes)
{
bool progress = false;
- nir_builder builder;
- if (modes & ~nir_var_function)
- nir_builder_init(&builder, nir_shader_get_entrypoint(shader));
-
- if (modes & nir_var_shader_out)
- progress |= lower_const_initializer(&builder, &shader->outputs);
-
- if (modes & nir_var_private)
- progress |= lower_const_initializer(&builder, &shader->globals);
-
- if (modes & nir_var_system_value)
- progress |= lower_const_initializer(&builder, &shader->system_values);
-
- 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);
- }
- }
- }
+ nir_foreach_function(function, shader) {
+ if (!function->impl)
+ continue;
+
+ bool impl_progress = false;
+
+ nir_builder builder;
+ nir_builder_init(&builder, function->impl);
+
+ if ((modes & nir_var_shader_out) && function->is_entrypoint)
+ impl_progress |= lower_const_initializer(&builder, &shader->outputs);
+
+ if ((modes & nir_var_private) && function->is_entrypoint)
+ impl_progress |= lower_const_initializer(&builder, &shader->outputs);
+
+ if ((modes & nir_var_system_value) && function->is_entrypoint)
+ impl_progress |= lower_const_initializer(&builder, &shader->outputs);
+
+ if (modes & nir_var_function)
+ 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);
}
}