summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/nir/nir_draw_helpers.c
diff options
context:
space:
mode:
authorEmma Anholt <emma@anholt.net>2023-05-02 15:40:51 -0700
committerMarge Bot <emma+marge@anholt.net>2023-05-16 18:57:28 +0000
commit0f25bb8283b7f1354549d4e74d7189ceb719bdbe (patch)
tree1317adc2388b29cc2617c9478e1873480a4f2caa /src/gallium/auxiliary/nir/nir_draw_helpers.c
parente31b7a3f9edc305cff4671cfadc7a99265d1b187 (diff)
downloadmesa-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/gallium/auxiliary/nir/nir_draw_helpers.c')
-rw-r--r--src/gallium/auxiliary/nir/nir_draw_helpers.c11
1 files changed, 2 insertions, 9 deletions
diff --git a/src/gallium/auxiliary/nir/nir_draw_helpers.c b/src/gallium/auxiliary/nir/nir_draw_helpers.c
index ad0d6d15ea1..2b362433f77 100644
--- a/src/gallium/auxiliary/nir/nir_draw_helpers.c
+++ b/src/gallium/auxiliary/nir/nir_draw_helpers.c
@@ -50,16 +50,9 @@ typedef struct {
static nir_ssa_def *
load_frag_coord(nir_builder *b)
{
- nir_foreach_shader_in_variable(var, b->shader) {
- if (var->data.location == VARYING_SLOT_POS)
- return nir_load_var(b, var);
- }
-
- nir_variable *pos = nir_variable_create(b->shader, nir_var_shader_in,
- glsl_vec4_type(), NULL);
- pos->data.location = VARYING_SLOT_POS;
+ nir_variable *pos = nir_get_variable_with_location(b->shader, nir_var_shader_in,
+ VARYING_SLOT_POS, glsl_vec4_type());
pos->data.interpolation = INTERP_MODE_NOPERSPECTIVE;
- pos->data.driver_location = b->shader->num_inputs++;
return nir_load_var(b, pos);
}