aboutsummaryrefslogtreecommitdiffstats
path: root/src/glsl/nir
diff options
context:
space:
mode:
authorJason Ekstrand <[email protected]>2015-10-02 18:15:06 -0700
committerJason Ekstrand <[email protected]>2015-10-02 21:21:16 -0700
commit050e4787d3526b8341dd76b59442356f9737ee96 (patch)
tree745536973c0279b53d8d23253b59b28630fc7f4e /src/glsl/nir
parentca941799ce76eac8afe2503fbacffee057e949d3 (diff)
nir: Add a nir_foreach_variable macro
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 <[email protected]>
Diffstat (limited to 'src/glsl/nir')
-rw-r--r--src/glsl/nir/nir.h3
-rw-r--r--src/glsl/nir/nir_lower_clip.c4
-rw-r--r--src/glsl/nir/nir_lower_io.c2
-rw-r--r--src/glsl/nir/nir_lower_outputs_to_temporaries.c2
-rw-r--r--src/glsl/nir/nir_lower_two_sided_color.c2
-rw-r--r--src/glsl/nir/nir_print.c14
-rw-r--r--src/glsl/nir/nir_validate.c12
7 files changed, 21 insertions, 18 deletions
diff --git a/src/glsl/nir/nir.h b/src/glsl/nir/nir.h
index c83ef50cee3..268fbc25a33 100644
--- a/src/glsl/nir/nir.h
+++ b/src/glsl/nir/nir.h
@@ -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;
diff --git a/src/glsl/nir/nir_lower_clip.c b/src/glsl/nir/nir_lower_clip.c
index 94d12b77af4..31ccfb2c02b 100644
--- a/src/glsl/nir/nir_lower_clip.c
+++ b/src/glsl/nir/nir_lower_clip.c
@@ -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
diff --git a/src/glsl/nir/nir_lower_io.c b/src/glsl/nir/nir_lower_io.c
index f32c09d04a2..30fad855e6f 100644
--- a/src/glsl/nir/nir_lower_io.c
+++ b/src/glsl/nir/nir_lower_io.c
@@ -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
diff --git a/src/glsl/nir/nir_lower_outputs_to_temporaries.c b/src/glsl/nir/nir_lower_outputs_to_temporaries.c
index 4ea5fd4f66b..80f43951b5c 100644
--- a/src/glsl/nir/nir_lower_outputs_to_temporaries.c
+++ b/src/glsl/nir/nir_lower_outputs_to_temporaries.c
@@ -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);
diff --git a/src/glsl/nir/nir_lower_two_sided_color.c b/src/glsl/nir/nir_lower_two_sided_color.c
index 131feef90af..db519bf513b 100644
--- a/src/glsl/nir/nir_lower_two_sided_color.c
+++ b/src/glsl/nir/nir_lower_two_sided_color.c
@@ -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
diff --git a/src/glsl/nir/nir_print.c b/src/glsl/nir/nir_print.c
index a19aa8b9132..3936bae078b 100644
--- a/src/glsl/nir/nir_print.c
+++ b/src/glsl/nir/nir_print.c
@@ -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);
}
diff --git a/src/glsl/nir/nir_validate.c b/src/glsl/nir/nir_validate.c
index 1c9993a9c80..c6fedf9b1ad 100644
--- a/src/glsl/nir/nir_validate.c
+++ b/src/glsl/nir/nir_validate.c
@@ -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);
}