From 0f25bb8283b7f1354549d4e74d7189ceb719bdbe Mon Sep 17 00:00:00 2001 From: Emma Anholt Date: Tue, 2 May 2023 15:40:51 -0700 Subject: nir: Add helpers for lazy var creation. This should make writing some lowering/meta code easier. It also keeps the num_inputs/outputs updated, when sometimes passes forgot to do so (for example, nir_lower_input_attachments updated for one of the two vars it creates). The names of the variables change in many cases, but it's probably nicer to see "VERT_ATTRIB_POS" than "in_0" or whatever. I've only converted mesa core (compiler and GL), not all the driver meta code. Reviewed-by: Alyssa Rosenzweig Reviewed-by: Erik Faye-Lund Part-of: --- src/compiler/nir/nir.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/compiler/nir/nir.h') diff --git a/src/compiler/nir/nir.h b/src/compiler/nir/nir.h index 05efa36aec1..1e35b6ae2fc 100644 --- a/src/compiler/nir/nir.h +++ b/src/compiler/nir/nir.h @@ -4044,6 +4044,19 @@ nir_variable *nir_local_variable_create(nir_function_impl *impl, const struct glsl_type *type, const char *name); +/* Gets the variable for the given mode and location, creating it (with the given + * type) if necessary. + */ +nir_variable * +nir_get_variable_with_location(nir_shader *shader, nir_variable_mode mode, int location, + const struct glsl_type *type); + +/* Creates a variable for the given mode and location. + */ +nir_variable * +nir_create_variable_with_location(nir_shader *shader, nir_variable_mode mode, int location, + const struct glsl_type *type); + nir_variable *nir_find_variable_with_location(nir_shader *shader, nir_variable_mode mode, unsigned location); -- cgit v1.2.1