compiler/nir: Add new flags to lower pack/unpack split instructions
[mesa.git] / src / compiler / nir / nir_lower_passthrough_edgeflags.c
index c570c8ef3333127933e569730df73154ee3ed61d..0afcaa0b1256b88ed2d4fdfa2682c2d5fb24852d 100644 (file)
@@ -39,6 +39,11 @@ lower_impl(nir_function_impl *impl)
                              glsl_vec4_type(), "edgeflag_in");
    in->data.location = VERT_ATTRIB_EDGEFLAG;
 
+   /* The edge flag is the last input in st/mesa. */
+   assert(shader->num_inputs == util_bitcount64(shader->info.inputs_read));
+   in->data.driver_location = shader->num_inputs++;
+   shader->info.inputs_read |= BITFIELD64_BIT(VERT_ATTRIB_EDGEFLAG);
+
    out = nir_variable_create(shader, nir_var_shader_out,
                              glsl_vec4_type(), "edgeflag_out");
    out->data.location = VARYING_SLOT_EDGE;
@@ -52,7 +57,5 @@ lower_impl(nir_function_impl *impl)
 
 void nir_lower_passthrough_edgeflags(nir_shader *shader)
 {
-   nir_function *function = nir_shader_get_entrypoint(shader);
-   if (function->impl)
-      lower_impl(function->impl);
+   lower_impl(nir_shader_get_entrypoint(shader));
 }