- nir_intrinsic_instr *copy =
- nir_intrinsic_instr_create(shader, nir_intrinsic_copy_var);
- copy->variables[0] = nir_deref_var_create(copy, newv);
- copy->variables[1] = nir_deref_var_create(copy, temp);
+ /* No need to copy the contents of a non-fb_fetch_output output variable
+ * to the temporary allocated for it, since its initial value is
+ * undefined.
+ */
+ if (src->data.mode == nir_var_shader_out &&
+ !src->data.fb_fetch_output)
+ continue;
+
+ /* Can't copy the contents of the temporary back to a read-only
+ * interface variable. The value of the temporary won't have been
+ * modified by the shader anyway.
+ */
+ if (dest->data.read_only)
+ continue;