Change pipeline_build_vertex_elements() so that VertexID is generated *after*
all user attributes rather than before.
diff --git a/icd/intel/pipeline.c b/icd/intel/pipeline.c
index 9d1a131..330313a 100644
--- a/icd/intel/pipeline.c
+++ b/icd/intel/pipeline.c
@@ -466,23 +466,6 @@
             (cmd_len - 2);
     dw++;
 
-    if (vs->uses & (INTEL_SHADER_USE_VID | INTEL_SHADER_USE_IID)) {
-        comps[0] = (vs->uses & INTEL_SHADER_USE_VID) ?
-            GEN6_VFCOMP_STORE_VID : GEN6_VFCOMP_STORE_0;
-        comps[1] = (vs->uses & INTEL_SHADER_USE_IID) ?
-            GEN6_VFCOMP_STORE_IID : GEN6_VFCOMP_NOSTORE;
-        comps[2] = GEN6_VFCOMP_NOSTORE;
-        comps[3] = GEN6_VFCOMP_NOSTORE;
-
-        dw[0] = GEN6_VE_STATE_DW0_VALID;
-        dw[1] = comps[0] << GEN6_VE_STATE_DW1_COMP0__SHIFT |
-                comps[1] << GEN6_VE_STATE_DW1_COMP1__SHIFT |
-                comps[2] << GEN6_VE_STATE_DW1_COMP2__SHIFT |
-                comps[3] << GEN6_VE_STATE_DW1_COMP3__SHIFT;
-
-        dw += 2;
-    }
-
     /* VERTEX_ELEMENT_STATE */
     for (i = 0; i < info->vi.attributeCount; i++) {
         const XGL_VERTEX_INPUT_ATTRIBUTE_DESCRIPTION *attr =
@@ -519,6 +502,23 @@
 
         dw += 2;
     }
+
+    if (vs->uses & (INTEL_SHADER_USE_VID | INTEL_SHADER_USE_IID)) {
+        comps[0] = (vs->uses & INTEL_SHADER_USE_VID) ?
+            GEN6_VFCOMP_STORE_VID : GEN6_VFCOMP_STORE_0;
+        comps[1] = (vs->uses & INTEL_SHADER_USE_IID) ?
+            GEN6_VFCOMP_STORE_IID : GEN6_VFCOMP_NOSTORE;
+        comps[2] = GEN6_VFCOMP_NOSTORE;
+        comps[3] = GEN6_VFCOMP_NOSTORE;
+
+        dw[0] = GEN6_VE_STATE_DW0_VALID;
+        dw[1] = comps[0] << GEN6_VE_STATE_DW1_COMP0__SHIFT |
+                comps[1] << GEN6_VE_STATE_DW1_COMP1__SHIFT |
+                comps[2] << GEN6_VE_STATE_DW1_COMP2__SHIFT |
+                comps[3] << GEN6_VE_STATE_DW1_COMP3__SHIFT;
+
+        dw += 2;
+    }
 }
 
 static void pipeline_build_gs(struct intel_pipeline *pipeline,