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;
* (This isn't the case with, for ex, FS inputs, which only need to agree
* on varying-slot w/ the VS outputs)
*/
-static void
-st_nir_assign_vs_in_locations(nir_shader *nir)
+void
+st_nir_assign_vs_in_locations(struct nir_shader *nir)
{
+ if (nir->info.stage != MESA_SHADER_VERTEX)
+ return;
+
bool removed_inputs = false;
nir->num_inputs = util_bitcount64(nir->info.inputs_read);
/* NIR already assigns dual-slot inputs to two locations so all we have
* to do is compact everything down.
*/
- if (var->data.location == VERT_ATTRIB_EDGEFLAG) {
- /* bit of a hack, mirroring st_translate_vertex_program */
- var->data.driver_location = nir->num_inputs++;
- } else if (nir->info.inputs_read & BITFIELD64_BIT(var->data.location)) {
+ if (nir->info.inputs_read & BITFIELD64_BIT(var->data.location)) {
var->data.driver_location =
util_bitcount64(nir->info.inputs_read &
BITFIELD64_MASK(var->data.location));
st_nir_assign_varying_locations(struct st_context *st, nir_shader *nir)
{
if (nir->info.stage == MESA_SHADER_VERTEX) {
- /* Needs special handling so drvloc matches the vbo state: */
- st_nir_assign_vs_in_locations(nir);
-
nir_assign_io_var_locations(&nir->outputs,
&nir->num_outputs,
nir->info.stage);
st_link_nir(struct gl_context *ctx,
struct gl_shader_program *shader_program);
+void st_nir_assign_vs_in_locations(struct nir_shader *nir);
void st_nir_assign_varying_locations(struct st_context *st,
struct nir_shader *nir);
nir_shader_gather_info(nir, nir_shader_get_entrypoint(nir));
+ st_nir_assign_vs_in_locations(nir);
st_nir_assign_varying_locations(st, nir);
st_nir_lower_samplers(screen, nir, NULL, NULL);