gallium/util: s/uint/enum tgsi_semantic/ in simple shader code
[mesa.git] / src / gallium / auxiliary / draw / draw_pipe_flatshade.c
index cd285e6f97c6cc564b33a0f7e0f2bc9040691816..2830435b99323c5b966da4065e37104206984f2a 100644 (file)
@@ -170,8 +170,9 @@ find_interp(const struct draw_fragment_shader *fs, int *indexed_interp,
    int interp;
    /* If it's gl_{Front,Back}{,Secondary}Color, pick up the mode
     * from the array we've filled before. */
-   if (semantic_name == TGSI_SEMANTIC_COLOR ||
-       semantic_name == TGSI_SEMANTIC_BCOLOR) {
+   if ((semantic_name == TGSI_SEMANTIC_COLOR ||
+        semantic_name == TGSI_SEMANTIC_BCOLOR) &&
+       semantic_index < 2) {
       interp = indexed_interp[semantic_index];
    } else {
       /* Otherwise, search in the FS inputs, with a decent default
@@ -216,7 +217,8 @@ static void flatshade_init_state( struct draw_stage *stage )
 
    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_semantic_name[i] == TGSI_SEMANTIC_COLOR &&
+             fs->info.input_semantic_index[i] < 2) {
             if (fs->info.input_interpolate[i] != TGSI_INTERPOLATE_COLOR)
                indexed_interp[fs->info.input_semantic_index[i]] = fs->info.input_interpolate[i];
          }
@@ -236,7 +238,8 @@ static void flatshade_init_state( struct draw_stage *stage )
                                info->output_semantic_index[i]);
       /* If it's flat, add it to the flat vector. */
 
-      if (interp == TGSI_INTERPOLATE_CONSTANT) {
+      if (interp == TGSI_INTERPOLATE_CONSTANT ||
+          (interp == TGSI_INTERPOLATE_COLOR && draw->rasterizer->flatshade)) {
          flat->flat_attribs[flat->num_flat_attribs] = i;
          flat->num_flat_attribs++;
       }