nir: Add a nir_foreach_variable macro
authorJason Ekstrand <jason.ekstrand@intel.com>
Sat, 3 Oct 2015 01:15:06 +0000 (18:15 -0700)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 3 Oct 2015 04:21:16 +0000 (21:21 -0700)
This is a common enough operation that it's nice to not have to think about
the arguments to foreach_list_typed every time.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/nir/nir.h
src/glsl/nir/nir_lower_clip.c
src/glsl/nir/nir_lower_io.c
src/glsl/nir/nir_lower_outputs_to_temporaries.c
src/glsl/nir/nir_lower_two_sided_color.c
src/glsl/nir/nir_print.c
src/glsl/nir/nir_validate.c

index c83ef50cee3f67d4a53d9713336df016716ca05c..268fbc25a337b8753c27ad0338ea12ecffd8dd5b 100644 (file)
@@ -365,6 +365,9 @@ typedef struct {
    const struct glsl_type *interface_type;
 } nir_variable;
 
+#define nir_foreach_variable(var, var_list) \
+   foreach_list_typed(nir_variable, var, node, var_list)
+
 typedef struct {
    struct exec_node node;
 
index 94d12b77af43ae8584b65ed46bae405c3ae31104..31ccfb2c02b5b0da97e3f31c8b755d8b7b5cc4c1 100644 (file)
@@ -218,7 +218,7 @@ nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables)
       return;
 
    /* find clipvertex/position outputs: */
-   foreach_list_typed(nir_variable, var, node, &shader->outputs) {
+   nir_foreach_variable(var, &shader->outputs) {
       int loc = var->data.driver_location;
 
       /* keep track of last used driver-location.. we'll be
@@ -310,7 +310,7 @@ nir_lower_clip_fs(nir_shader *shader, unsigned ucp_enables)
    if (!ucp_enables)
       return;
 
-   foreach_list_typed(nir_variable, var, node, &shader->inputs) {
+   nir_foreach_variable(var, &shader->inputs) {
       int loc = var->data.driver_location;
 
       /* keep track of last used driver-location.. we'll be
index f32c09d04a2ae3c59f44bbf5689e81d468acf07c..30fad855e6f1395c35a92c8bf5db467f45d6411f 100644 (file)
@@ -47,7 +47,7 @@ nir_assign_var_locations(struct exec_list *var_list, unsigned *size,
 {
    unsigned location = 0;
 
-   foreach_list_typed(nir_variable, var, node, var_list) {
+   nir_foreach_variable(var, var_list) {
       /*
        * UBO's have their own address spaces, so don't count them towards the
        * number of global uniforms
index 4ea5fd4f66b4f3a274f315dcccec9f0a5de1eb46..80f43951b5caef91cd7a5e26b7a288941d37782a 100644 (file)
@@ -84,7 +84,7 @@ nir_lower_outputs_to_temporaries(nir_shader *shader)
    /* Walk over all of the outputs turn each output into a temporary and
     * make a new variable for the actual output.
     */
-   foreach_list_typed(nir_variable, var, node, &state.old_outputs) {
+   nir_foreach_variable(var, &state.old_outputs) {
       nir_variable *output = ralloc(shader, nir_variable);
       memcpy(output, var, sizeof *output);
 
index 131feef90af9447ccf17b4b4b4b0d8cdee3f4933..db519bf513b56cc8b9d63d9394a2645ddfffd295 100644 (file)
@@ -83,7 +83,7 @@ setup_inputs(lower_2side_state *state)
    int maxloc = -1;
 
    /* find color/face inputs: */
-   foreach_list_typed(nir_variable, var, node, &state->shader->inputs) {
+   nir_foreach_variable(var, &state->shader->inputs) {
       int loc = var->data.driver_location;
 
       /* keep track of last used driver-location.. we'll be
index a19aa8b91326100f3a89813fb9295c4dcd26b5c3..3936bae078b07c525137e7a3beb746058038cc5b 100644 (file)
@@ -453,7 +453,7 @@ print_intrinsic_instr(nir_intrinsic_instr *instr, print_state *state)
       return;
    }
 
-   foreach_list_typed(nir_variable, var, node, var_list) {
+   nir_foreach_variable(var, var_list) {
       if ((var->data.driver_location == instr->const_index[0]) &&
           var->name) {
          fprintf(fp, "\t/* %s */", var->name);
@@ -872,7 +872,7 @@ print_function_impl(nir_function_impl *impl, print_state *state)
 
    fprintf(fp, "{\n");
 
-   foreach_list_typed(nir_variable, var, node, &impl->locals) {
+   nir_foreach_variable(var, &impl->locals) {
       fprintf(fp, "\t");
       print_var_decl(var, state);
    }
@@ -970,23 +970,23 @@ nir_print_shader(nir_shader *shader, FILE *fp)
 
    fprintf(fp, "shader: %s\n", gl_shader_stage_name(shader->stage));
 
-   foreach_list_typed(nir_variable, var, node, &shader->uniforms) {
+   nir_foreach_variable(var, &shader->uniforms) {
       print_var_decl(var, &state);
    }
 
-   foreach_list_typed(nir_variable, var, node, &shader->inputs) {
+   nir_foreach_variable(var, &shader->inputs) {
       print_var_decl(var, &state);
    }
 
-   foreach_list_typed(nir_variable, var, node, &shader->outputs) {
+   nir_foreach_variable(var, &shader->outputs) {
       print_var_decl(var, &state);
    }
 
-   foreach_list_typed(nir_variable, var, node, &shader->globals) {
+   nir_foreach_variable(var, &shader->globals) {
       print_var_decl(var, &state);
    }
 
-   foreach_list_typed(nir_variable, var, node, &shader->system_values) {
+   nir_foreach_variable(var, &shader->system_values) {
       print_var_decl(var, &state);
    }
 
index 1c9993a9c80d9b2dc3c800fb831f0eb6265be185..c6fedf9b1adecc141e85d5fa43e7be895a0e0739 100644 (file)
@@ -934,7 +934,7 @@ validate_function_impl(nir_function_impl *impl, validate_state *state)
    state->parent_node = &impl->cf_node;
 
    exec_list_validate(&impl->locals);
-   foreach_list_typed(nir_variable, var, node, &impl->locals) {
+   nir_foreach_variable(var, &impl->locals) {
       validate_var_decl(var, false, state);
    }
 
@@ -1016,27 +1016,27 @@ nir_validate_shader(nir_shader *shader)
    state.shader = shader;
 
    exec_list_validate(&shader->uniforms);
-   foreach_list_typed(nir_variable, var, node, &shader->uniforms) {
+   nir_foreach_variable(var, &shader->uniforms) {
       validate_var_decl(var, true, &state);
    }
 
    exec_list_validate(&shader->inputs);
-   foreach_list_typed(nir_variable, var, node, &shader->inputs) {
+   nir_foreach_variable(var, &shader->inputs) {
      validate_var_decl(var, true, &state);
    }
 
    exec_list_validate(&shader->outputs);
-   foreach_list_typed(nir_variable, var, node, &shader->outputs) {
+   nir_foreach_variable(var, &shader->outputs) {
      validate_var_decl(var, true, &state);
    }
 
    exec_list_validate(&shader->globals);
-   foreach_list_typed(nir_variable, var, node, &shader->globals) {
+   nir_foreach_variable(var, &shader->globals) {
      validate_var_decl(var, true, &state);
    }
 
    exec_list_validate(&shader->system_values);
-   foreach_list_typed(nir_variable, var, node, &shader->system_values) {
+   nir_foreach_variable(var, &shader->system_values) {
      validate_var_decl(var, true, &state);
    }