memcpy(state->sysval, program.sysvals, sizeof(state->sysval[0]) * state->sysval_count);
meta->midgard1.uniform_count = MIN2(program.uniform_count, program.uniform_cutoff);
- meta->attribute_count = program.attribute_count;
- meta->varying_count = program.varying_count;
meta->midgard1.work_count = program.work_register_count;
+ switch (s->info.stage) {
+ case MESA_SHADER_VERTEX:
+ meta->attribute_count = util_bitcount64(s->info.inputs_read);
+ meta->varying_count = util_bitcount64(s->info.outputs_written);
+ break;
+ case MESA_SHADER_FRAGMENT:
+ meta->attribute_count = 0;
+ meta->varying_count = util_bitcount64(s->info.inputs_read);
+ break;
+ default:
+ unreachable("Unknown shader state");
+ }
+
state->can_discard = s->info.fs.uses_discard;
state->writes_point_size = s->info.outputs_written & VARYING_SLOT_PSIZ;
state->reads_point_coord = s->info.inputs_read & VARYING_SLOT_PNTC;
unsigned default_vec4_swizzle = panfrost_get_default_swizzle(4);
/* Iterate the varyings and emit the corresponding descriptor */
- for (unsigned i = 0; i < program.varying_count; ++i) {
+ for (unsigned i = 0; i < meta->varying_count; ++i) {
unsigned location = program.varyings[i];
/* Default to a vec4 varying */
program->sysval_count = ctx->sysval_count;
memcpy(program->sysvals, ctx->sysvals, sizeof(ctx->sysvals[0]) * ctx->sysval_count);
- program->attribute_count = (ctx->stage == MESA_SHADER_VERTEX) ? nir->num_inputs : 0;
- program->varying_count = max_varying + 1; /* Fencepost off-by-one */
-
nir_foreach_function(func, nir) {
if (!func->impl)
continue;