st/glsl_to_tgsi: make use of tgsi_get_gl_varying_semantic()
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 13 Nov 2017 00:58:59 +0000 (11:58 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Tue, 14 Nov 2017 21:26:34 +0000 (08:26 +1100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/mesa/state_tracker/st_program.c

index 70b63a374717b4ccb6a0bcf384ddb0a73051cc3a..7c8f65a3d631a6929f92bc2303fe454831616d3c 100644 (file)
@@ -1318,79 +1318,19 @@ st_translate_program_common(struct st_context *st,
     * Convert Mesa program inputs to TGSI input register semantics.
     */
    for (attr = 0; attr < VARYING_SLOT_MAX; attr++) {
-      if ((prog->info.inputs_read & BITFIELD64_BIT(attr)) != 0) {
-         const GLuint slot = num_inputs++;
+      if ((prog->info.inputs_read & BITFIELD64_BIT(attr)) == 0)
+         continue;
 
-         inputMapping[attr] = slot;
-         inputSlotToAttr[slot] = attr;
+      unsigned slot = num_inputs++;
 
-         switch (attr) {
-         case VARYING_SLOT_PRIMITIVE_ID:
-            assert(tgsi_processor == PIPE_SHADER_GEOMETRY);
-            input_semantic_name[slot] = TGSI_SEMANTIC_PRIMID;
-            input_semantic_index[slot] = 0;
-            break;
-         case VARYING_SLOT_POS:
-            input_semantic_name[slot] = TGSI_SEMANTIC_POSITION;
-            input_semantic_index[slot] = 0;
-            break;
-         case VARYING_SLOT_COL0:
-            input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
-            input_semantic_index[slot] = 0;
-            break;
-         case VARYING_SLOT_COL1:
-            input_semantic_name[slot] = TGSI_SEMANTIC_COLOR;
-            input_semantic_index[slot] = 1;
-            break;
-         case VARYING_SLOT_FOGC:
-            input_semantic_name[slot] = TGSI_SEMANTIC_FOG;
-            input_semantic_index[slot] = 0;
-            break;
-         case VARYING_SLOT_CLIP_VERTEX:
-            input_semantic_name[slot] = TGSI_SEMANTIC_CLIPVERTEX;
-            input_semantic_index[slot] = 0;
-            break;
-         case VARYING_SLOT_CLIP_DIST0:
-            input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
-            input_semantic_index[slot] = 0;
-            break;
-         case VARYING_SLOT_CLIP_DIST1:
-            input_semantic_name[slot] = TGSI_SEMANTIC_CLIPDIST;
-            input_semantic_index[slot] = 1;
-            break;
-         case VARYING_SLOT_CULL_DIST0:
-         case VARYING_SLOT_CULL_DIST1:
-            /* these should have been lowered by GLSL */
-            assert(0);
-            break;
-         case VARYING_SLOT_PSIZ:
-            input_semantic_name[slot] = TGSI_SEMANTIC_PSIZE;
-            input_semantic_index[slot] = 0;
-            break;
-         case VARYING_SLOT_TEX0:
-         case VARYING_SLOT_TEX1:
-         case VARYING_SLOT_TEX2:
-         case VARYING_SLOT_TEX3:
-         case VARYING_SLOT_TEX4:
-         case VARYING_SLOT_TEX5:
-         case VARYING_SLOT_TEX6:
-         case VARYING_SLOT_TEX7:
-            if (st->needs_texcoord_semantic) {
-               input_semantic_name[slot] = TGSI_SEMANTIC_TEXCOORD;
-               input_semantic_index[slot] = attr - VARYING_SLOT_TEX0;
-               break;
-            }
-            /* fall through */
-         case VARYING_SLOT_VAR0:
-         default:
-            assert(attr >= VARYING_SLOT_VAR0 ||
-                   (attr >= VARYING_SLOT_TEX0 && attr <= VARYING_SLOT_TEX7));
-            input_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
-            input_semantic_index[slot] =
-               st_get_generic_varying_index(st, attr);
-            break;
-         }
-      }
+      inputMapping[attr] = slot;
+      inputSlotToAttr[slot] = attr;
+
+      unsigned semantic_name, semantic_index;
+      tgsi_get_gl_varying_semantic(attr, st->needs_texcoord_semantic,
+                                   &semantic_name, &semantic_index);
+      input_semantic_name[slot] = semantic_name;
+      input_semantic_index[slot] = semantic_index;
    }
 
    /* Also add patch inputs. */