Mesa (master): nir: Add a nir_shader_preserve_all_metadata helper

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 11 05:28:39 UTC 2020


Module: Mesa
Branch: master
Commit: b0d1f9a72ff6e1c7164dc22ff5eb3e817f245d13
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=b0d1f9a72ff6e1c7164dc22ff5eb3e817f245d13

Author: Jason Ekstrand <jason at jlekstrand.net>
Date:   Thu May 21 21:37:33 2020 -0500

nir: Add a nir_shader_preserve_all_metadata helper

There are some passes which really work on the shader level and it's
easier if we have a helper which preserves metadata on the whole shader.

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5171>

---

 src/compiler/nir/nir.h          | 2 ++
 src/compiler/nir/nir_metadata.c | 9 +++++++++
 2 files changed, 11 insertions(+)

diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h
index 9d0110ebe94..b0316df4ffa 100644
--- a/src/compiler/nir/nir.h
+++ b/src/compiler/nir/nir.h
@@ -3294,6 +3294,8 @@ nir_function_impl *nir_cf_node_get_function(nir_cf_node *node);
 void nir_metadata_require(nir_function_impl *impl, nir_metadata required, ...);
 /** dirties all but the preserved metadata */
 void nir_metadata_preserve(nir_function_impl *impl, nir_metadata preserved);
+/** Preserves all metadata for the given shader */
+void nir_shader_preserve_all_metadata(nir_shader *shader);
 
 /** creates an instruction with default swizzle/writemask/etc. with NULL registers */
 nir_alu_instr *nir_alu_instr_create(nir_shader *shader, nir_op op);
diff --git a/src/compiler/nir/nir_metadata.c b/src/compiler/nir/nir_metadata.c
index e681ba34f75..6122394d8b5 100644
--- a/src/compiler/nir/nir_metadata.c
+++ b/src/compiler/nir/nir_metadata.c
@@ -59,6 +59,15 @@ nir_metadata_preserve(nir_function_impl *impl, nir_metadata preserved)
    impl->valid_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);
+   }
+}
+
 #ifndef NDEBUG
 /**
  * Make sure passes properly invalidate metadata (part 1).



More information about the mesa-commit mailing list