unsigned loc = var->data.driver_location;
unsigned sz = glsl_type_size(var->type, FALSE);
- for (int c = loc; c < (loc + sz); ++c) {
- program->varyings[c] = var->data.location;
- max_varying = MAX2(max_varying, c);
+ for (int c = 0; c < sz; ++c) {
+ program->varyings[loc + c] = var->data.location + c;
+ max_varying = MAX2(max_varying, loc + c);
}
}
unsigned default_vec4_swizzle = panfrost_get_default_swizzle(4);
/* Iterate the varyings and emit the corresponding descriptor */
- unsigned general_purpose_count = 0;
-
for (unsigned i = 0; i < program.varying_count; ++i) {
unsigned location = program.varyings[i];
state->reads_point_coord = true;
} else {
v.index = 0;
- v.src_offset = 16 * (general_purpose_count++);
}
state->varyings[i] = v;
+ state->varyings_loc[i] = location;
}
-
- /* Set the stride for the general purpose fp32 vec4 varyings */
- state->general_varying_stride = (4 * 4) * general_purpose_count;
}
struct panfrost_shader_state *vs = &ctx->vs->variants[ctx->vs->active_variant];
struct panfrost_shader_state *fs = &ctx->fs->variants[ctx->fs->active_variant];
+ unsigned int num_gen_varyings = 0;
/* Allocate the varying descriptor */
struct panfrost_transfer trans = panfrost_allocate_transient(ctx,
vs_size + fs_size);
+ /*
+ * Assign ->src_offset now that we know about all the general purpose
+ * varyings that will be used by the fragment and vertex shaders.
+ */
+ for (unsigned i = 0; i < vs->tripipe->varying_count; i++) {
+ /*
+ * General purpose varyings have ->index set to 0, skip other
+ * entries.
+ */
+ if (vs->varyings[i].index)
+ continue;
+
+ vs->varyings[i].src_offset = 16 * (num_gen_varyings++);
+ }
+
+ for (unsigned i = 0; i < fs->tripipe->varying_count; i++) {
+ unsigned j;
+
+ if (fs->varyings[i].index)
+ continue;
+
+ /*
+ * Re-use the VS general purpose varying pos if it exists,
+ * create a new one otherwise.
+ */
+ for (j = 0; j < vs->tripipe->varying_count; j++) {
+ if (fs->varyings_loc[i] == vs->varyings_loc[j])
+ break;
+ }
+
+ if (j < vs->tripipe->varying_count)
+ fs->varyings[i].src_offset = vs->varyings[j].src_offset;
+ else
+ fs->varyings[i].src_offset = 16 * (num_gen_varyings++);
+ }
+
memcpy(trans.cpu, vs->varyings, vs_size);
memcpy(trans.cpu + vs_size, fs->varyings, fs_size);
union mali_attr varyings[PIPE_MAX_ATTRIBS];
unsigned idx = 0;
- /* General varyings -- use the VS's, since those are more likely to be
- * accurate on desktop */
-
- panfrost_emit_varyings(ctx, &varyings[idx++],
- vs->general_varying_stride, invocation_count);
+ panfrost_emit_varyings(ctx, &varyings[idx++], num_gen_varyings * 16,
+ invocation_count);
/* fp32 vec4 gl_Position */
ctx->payload_tiler.postfix.position_varying =