uint64_t *used;
assert(mode == nir_var_shader_in || mode == nir_var_shader_out);
- struct exec_list *var_list = nir_variable_list_for_mode(shader, mode);
- nir_foreach_variable_safe(var, var_list) {
+ nir_foreach_variable_with_modes_safe(var, shader, mode) {
if (var->data.patch)
used = used_by_other_stage_patches;
else
var->data.location = 0;
var->data.mode = nir_var_shader_temp;
- exec_node_remove(&var->node);
- exec_list_push_tail(&shader->globals, &var->node);
-
progress = true;
}
}
* TODO: allow better packing of complex types.
*/
static void
-get_unmoveable_components_masks(struct exec_list *var_list,
+get_unmoveable_components_masks(nir_shader *shader,
+ nir_variable_mode mode,
struct assigned_comps *comps,
gl_shader_stage stage,
bool default_to_smooth_interp)
{
- nir_foreach_variable_safe(var, var_list) {
+ nir_foreach_variable_with_modes_safe(var, shader, mode) {
assert(var->data.location >= 0);
/* Only remap things that aren't built-ins. */
}
static void
-remap_slots_and_components(struct exec_list *var_list, gl_shader_stage stage,
+remap_slots_and_components(nir_shader *shader, nir_variable_mode mode,
struct varying_loc (*remap)[4],
uint64_t *slots_used, uint64_t *out_slots_read,
uint32_t *p_slots_used, uint32_t *p_out_slots_read)
{
+ const gl_shader_stage stage = shader->info.stage;
uint64_t out_slots_read_tmp[2] = {0};
uint64_t slots_used_tmp[2] = {0};
/* We don't touch builtins so just copy the bitmask */
slots_used_tmp[0] = *slots_used & BITFIELD64_RANGE(0, VARYING_SLOT_VAR0);
- nir_foreach_variable(var, var_list) {
+ nir_foreach_variable_with_modes(var, shader, mode) {
assert(var->data.location >= 0);
/* Only remap things that aren't built-ins */
struct assigned_comps *assigned_comps,
bool default_to_smooth_interp)
{
- struct exec_list *input_list = &consumer->inputs;
- struct exec_list *output_list = &producer->outputs;
struct varying_loc remap[MAX_VARYINGS_INCL_PATCH][4] = {{{0}, {0}}};
struct varying_component *varying_comp_info;
unsigned varying_comp_info_size;
uint64_t zero = 0;
uint32_t zero32 = 0;
- remap_slots_and_components(input_list, consumer->info.stage, remap,
+ remap_slots_and_components(consumer, nir_var_shader_in, remap,
&consumer->info.inputs_read, &zero,
&consumer->info.patch_inputs_read, &zero32);
- remap_slots_and_components(output_list, producer->info.stage, remap,
+ remap_slots_and_components(producer, nir_var_shader_out, remap,
&producer->info.outputs_written,
&producer->info.outputs_read,
&producer->info.patch_outputs_written,
struct assigned_comps assigned_comps[MAX_VARYINGS_INCL_PATCH] = {{0}};
- get_unmoveable_components_masks(&producer->outputs, assigned_comps,
+ get_unmoveable_components_masks(producer, nir_var_shader_out,
+ assigned_comps,
producer->info.stage,
default_to_smooth_interp);
- get_unmoveable_components_masks(&consumer->inputs, assigned_comps,
+ get_unmoveable_components_masks(consumer, nir_var_shader_in,
+ assigned_comps,
consumer->info.stage,
default_to_smooth_interp);
static void
insert_sorted(struct exec_list *var_list, nir_variable *new_var)
{
- nir_foreach_variable(var, var_list) {
+ nir_foreach_variable_in_list(var, var_list) {
if (var->data.location > new_var->data.location) {
exec_node_insert_node_before(&var->node, &new_var->node);
return;
}
static void
-sort_varyings(struct exec_list *var_list)
+sort_varyings(nir_shader *shader, nir_variable_mode mode,
+ struct exec_list *sorted_list)
{
- struct exec_list new_list;
- exec_list_make_empty(&new_list);
- nir_foreach_variable_safe(var, var_list) {
+ exec_list_make_empty(sorted_list);
+ nir_foreach_variable_with_modes_safe(var, shader, mode) {
exec_node_remove(&var->node);
- insert_sorted(&new_list, var);
+ insert_sorted(sorted_list, var);
}
- exec_list_move_nodes_to(&new_list, var_list);
}
void
-nir_assign_io_var_locations(struct exec_list *var_list, unsigned *size,
- gl_shader_stage stage)
+nir_assign_io_var_locations(nir_shader *shader, nir_variable_mode mode,
+ unsigned *size, gl_shader_stage stage)
{
unsigned location = 0;
unsigned assigned_locations[VARYING_SLOT_TESS_MAX];
uint64_t processed_locs[2] = {0};
- sort_varyings(var_list);
+ struct exec_list io_vars;
+ sort_varyings(shader, mode, &io_vars);
int UNUSED last_loc = 0;
bool last_partial = false;
- nir_foreach_variable(var, var_list) {
+ nir_foreach_variable_in_list(var, &io_vars) {
const struct glsl_type *type = var->type;
if (nir_is_per_vertex_io(var, stage) || var->data.per_view) {
assert(glsl_type_is_array(type));
if (last_partial)
location++;
+ exec_list_append(&shader->variables, &io_vars);
*size = location;
}