diff options
author | Emma Anholt <emma@anholt.net> | 2023-05-02 15:40:51 -0700 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2023-05-16 18:57:28 +0000 |
commit | 0f25bb8283b7f1354549d4e74d7189ceb719bdbe (patch) | |
tree | 1317adc2388b29cc2617c9478e1873480a4f2caa /src/compiler/nir/nir.h | |
parent | e31b7a3f9edc305cff4671cfadc7a99265d1b187 (diff) | |
download | mesa-0f25bb8283b7f1354549d4e74d7189ceb719bdbe.tar.gz |
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 <alyssa@rosenzweig.io>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22809>
Diffstat (limited to 'src/compiler/nir/nir.h')
-rw-r--r-- | src/compiler/nir/nir.h | 13 |
1 files changed, 13 insertions, 0 deletions
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); |