Set up VertexIndex builtin properly

Bug: b/124177079
Change-Id: Ie51c9e8865f12583ece35a1d1d6c558d2ed1281b
Reviewed-on: https://swiftshader-review.googlesource.com/c/24590
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Pipeline/VertexProgram.cpp b/src/Pipeline/VertexProgram.cpp
index 7bb498f..b8ccf34 100644
--- a/src/Pipeline/VertexProgram.cpp
+++ b/src/Pipeline/VertexProgram.cpp
@@ -52,20 +52,13 @@
 
 		enableIndex = 0;
 
-		//if(shader->isVertexIdDeclared())
-		//{
-		//	if(state.textureSampling)
-		//	{
-		//		vertexID = Int4(index);
-		//	}
-		//	else
-		//	{
-		//		vertexID = Insert(vertexID, As<Int>(index), 0);
-		//		vertexID = Insert(vertexID, As<Int>(index + 1), 1);
-		//		vertexID = Insert(vertexID, As<Int>(index + 2), 2);
-		//		vertexID = Insert(vertexID, As<Int>(index + 3), 3);
-		//	}
-		//}
+		auto it = spirvShader->inputBuiltins.find(spv::BuiltInVertexIndex);
+		if (it != spirvShader->inputBuiltins.end())
+		{
+			assert(it->second.SizeInComponents == 1);
+			(*routine.lvalues[it->second.Id])[it->second.FirstComponent] =
+					As<Float4>(Int4(index) + Int4(0, 1, 2, 3));
+		}
 
 		spirvShader->emit(&routine);
 
diff --git a/src/Pipeline/VertexProgram.hpp b/src/Pipeline/VertexProgram.hpp
index 773118f..358ed5f 100644
--- a/src/Pipeline/VertexProgram.hpp
+++ b/src/Pipeline/VertexProgram.hpp
@@ -37,9 +37,6 @@
 		Int enableIndex;
 		Array<Int4, 1 + 24> enableStack;
 
-		Int instanceID;
-		Int4 vertexID;
-
 		void program(UInt &index) override;
 		RValue<Pointer<Byte>> uniformAddress(int bufferIndex, unsigned int index);
 		RValue<Pointer<Byte>> uniformAddress(int bufferIndex, unsigned int index, Int &offset);