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 <kenneth@whitecape.org>
This commit is contained in:
@@ -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;
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user