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@collabora.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5171>
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);
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).