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);