nir/gl_nir_linker: Use nir_foreach_variable_with_modes

Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5966>
diff --git a/src/compiler/glsl/gl_nir_linker.c b/src/compiler/glsl/gl_nir_linker.c
index 4a7a316..68ecc7e 100644
--- a/src/compiler/glsl/gl_nir_linker.c
+++ b/src/compiler/glsl/gl_nir_linker.c
@@ -311,12 +311,12 @@
 }
 
 static bool
-add_vars_from_list(const struct gl_context *ctx,
+add_vars_with_mode(const struct gl_context *ctx,
                    struct gl_shader_program *prog, struct set *resource_set,
-                   const struct exec_list *var_list, unsigned stage,
-                   GLenum programInterface)
+                   nir_shader *nir, nir_variable_mode mode,
+                   unsigned stage, GLenum programInterface)
 {
-   nir_foreach_variable(var, var_list) {
+   nir_foreach_variable_with_modes(var, nir, mode) {
       if (var->data.how_declared == nir_var_hidden)
          continue;
 
@@ -405,15 +405,18 @@
 
    switch (programInterface) {
    case GL_PROGRAM_INPUT: {
-      bool result = add_vars_from_list(ctx, prog, resource_set,
-                                       &nir->inputs, stage, programInterface);
-      result &= add_vars_from_list(ctx, prog, resource_set, &nir->system_values,
+      bool result = add_vars_with_mode(ctx, prog, resource_set,
+                                       nir, nir_var_shader_in,
+                                       stage, programInterface);
+      result &= add_vars_with_mode(ctx, prog, resource_set,
+                                   nir, nir_var_system_value,
                                    stage, programInterface);
       return result;
    }
    case GL_PROGRAM_OUTPUT:
-      return add_vars_from_list(ctx, prog, resource_set, &nir->outputs, stage,
-                                programInterface);
+      return add_vars_with_mode(ctx, prog, resource_set,
+                                nir, nir_var_shader_out,
+                                stage, programInterface);
    default:
       assert("!Should not get here");
       break;