- /* Find which vertex shader outputs are colors, make a list */
- flat->num_color_attribs = 0;
- flat->num_spec_attribs = 0;
- for (i = 0; i < vs->info.num_outputs; i++) {
- if (vs->info.output_semantic_name[i] == TGSI_SEMANTIC_COLOR ||
- vs->info.output_semantic_name[i] == TGSI_SEMANTIC_BCOLOR) {
- if (vs->info.output_semantic_index[i] == 0)
- flat->color_attribs[flat->num_color_attribs++] = i;
- else
- flat->spec_attribs[flat->num_spec_attribs++] = i;
+ /* XXX: this code is a near exact copy of the one in clip_init_state.
+ * The latter also cares about perspective though.
+ */
+
+ /* First pick up the interpolation mode for
+ * gl_Color/gl_SecondaryColor, with the correct default.
+ */
+ int indexed_interp[2];
+ indexed_interp[0] = indexed_interp[1] = draw->rasterizer->flatshade ?
+ TGSI_INTERPOLATE_CONSTANT : TGSI_INTERPOLATE_PERSPECTIVE;
+
+ if (fs) {
+ for (i = 0; i < fs->info.num_inputs; i++) {
+ if (fs->info.input_semantic_name[i] == TGSI_SEMANTIC_COLOR) {
+ if (fs->info.input_interpolate[i] != TGSI_INTERPOLATE_COLOR)
+ indexed_interp[fs->info.input_semantic_index[i]] = fs->info.input_interpolate[i];
+ }
+ }
+ }
+
+ /* Then resolve the interpolation mode for every output attribute.
+ *
+ * Given how the rest of the code, the most efficient way is to
+ * have a vector of flat-mode attributes.
+ */
+ flat->num_flat_attribs = 0;
+ for (i = 0; i < info->num_outputs; i++) {
+ /* Find the interpolation mode for a specific attribute */
+ int interp = find_interp(fs, indexed_interp,
+ info->output_semantic_name[i],
+ info->output_semantic_index[i]);
+ /* If it's flat, add it to the flat vector. */
+
+ if (interp == TGSI_INTERPOLATE_CONSTANT) {
+ flat->flat_attribs[flat->num_flat_attribs] = i;
+ flat->num_flat_attribs++;
+ }
+ }
+ /* Search the extra vertex attributes */
+ for (j = 0; j < draw->extra_shader_outputs.num; j++) {
+ /* Find the interpolation mode for a specific attribute */
+ int interp = find_interp(fs, indexed_interp,
+ draw->extra_shader_outputs.semantic_name[j],
+ draw->extra_shader_outputs.semantic_index[j]);
+ /* If it's flat, add it to the flat vector. */
+ if (interp == TGSI_INTERPOLATE_CONSTANT) {
+ flat->flat_attribs[flat->num_flat_attribs] = i + j;
+ flat->num_flat_attribs++;