-/**
- * Update the type of the combined array (including interface block nesting).
- */
-static void
-update_type(nir_variable *var, gl_shader_stage stage, unsigned length)
-{
- const struct glsl_type *type = glsl_array_type(glsl_float_type(), length, 0);
-
- if (nir_is_per_vertex_io(var, stage))
- type = glsl_array_type(type, glsl_get_length(var->type), 0);
-
- var->type = type;
-}
-
-static void
-rewrite_clip_cull_deref(nir_builder *b,
- nir_deref_instr *deref,
- const struct glsl_type *type,
- unsigned tail_offset)
-{
- deref->type = type;
-
- if (glsl_type_is_array(type)) {
- const struct glsl_type *child_type = glsl_get_array_element(type);
- nir_foreach_use(src, &deref->dest.ssa) {
- rewrite_clip_cull_deref(b, nir_instr_as_deref(src->parent_instr),
- child_type, tail_offset);
- }
- } else {
- assert(glsl_type_is_scalar(type));
-
- /* This is the end of the line. Add the tail offset if needed */
- if (tail_offset > 0) {
- b->cursor = nir_before_instr(&deref->instr);
- assert(deref->deref_type == nir_deref_type_array);
- nir_ssa_def *index = nir_iadd(b, deref->arr.index.ssa,
- nir_imm_int(b, tail_offset));
- nir_instr_rewrite_src(&deref->instr, &deref->arr.index,
- nir_src_for_ssa(index));
- }
- }
-}
-
-static void
-rewrite_references(nir_builder *b,
- nir_instr *instr,
- nir_variable *combined,
- unsigned cull_offset)
-{
- if (instr->type != nir_instr_type_deref)
- return;
-
- nir_deref_instr *deref = nir_instr_as_deref(instr);
- if (deref->deref_type != nir_deref_type_var)
- return;
-
- if (deref->var->data.mode != combined->data.mode)
- return;
-
- const unsigned location = deref->var->data.location;
- if (location != VARYING_SLOT_CLIP_DIST0 &&
- location != VARYING_SLOT_CULL_DIST0)
- return;
-
- deref->var = combined;
- if (location == VARYING_SLOT_CULL_DIST0)
- rewrite_clip_cull_deref(b, deref, combined->type, cull_offset);
- else
- rewrite_clip_cull_deref(b, deref, combined->type, 0);
-}
-