Wire up FS input to the shader

Bug: b/124177079
Change-Id: I8dac28d2c55ce1c4eb9a815bfad56ba917be32c5
Reviewed-on: https://swiftshader-review.googlesource.com/c/24593
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Chris Forbes <chrisforbes@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/src/Device/PixelProcessor.cpp b/src/Device/PixelProcessor.cpp
index 6579a75..fcbee9f 100644
--- a/src/Device/PixelProcessor.cpp
+++ b/src/Device/PixelProcessor.cpp
@@ -709,44 +709,6 @@
 
 		const bool point = context->isDrawPoint();
 
-		/* TODO: bring back interpolants by some mechanism */
-//		for(int interpolant = 0; interpolant < MAX_FRAGMENT_INPUTS; interpolant++)
-//		{
-//			for(int component = 0; component < 4; component++)
-//			{
-//				const Shader::Semantic &semantic = context->pixelShader->getInput(interpolant, component);
-//
-//				if(semantic.active())
-//				{
-//					bool flat = point;
-//
-//					switch(semantic.usage)
-//					{
-//					case Shader::USAGE_TEXCOORD: flat = false;                  break;
-//					case Shader::USAGE_COLOR:    flat = semantic.flat || point; break;
-//					}
-//
-//					state.interpolant[interpolant].component |= 1 << component;
-//
-//					if(flat)
-//					{
-//						state.interpolant[interpolant].flat |= 1 << component;
-//					}
-//				}
-//			}
-//		}
-//
-//		if(state.centroid)
-//		{
-//			for(int interpolant = 0; interpolant < MAX_FRAGMENT_INPUTS; interpolant++)
-//			{
-//				for(int component = 0; component < 4; component++)
-//				{
-//					state.interpolant[interpolant].centroid = context->pixelShader->getInput(interpolant, 0).centroid;
-//				}
-//			}
-//		}
-
 		state.hash = state.computeHash();
 
 		return state;
diff --git a/src/Device/PixelProcessor.hpp b/src/Device/PixelProcessor.hpp
index 7a92dc5..268e127 100644
--- a/src/Device/PixelProcessor.hpp
+++ b/src/Device/PixelProcessor.hpp
@@ -83,15 +83,6 @@
 			VkLogicOp logicalOperation : BITS(VK_LOGIC_OP_END_RANGE);
 
 			Sampler::State sampler[TEXTURE_IMAGE_UNITS];
-
-			struct Interpolant
-			{
-				unsigned char component : 4;
-				unsigned char flat : 4;
-				bool centroid : 1;
-			};
-
-			Interpolant interpolant[MAX_FRAGMENT_INPUTS];
 		};
 
 		struct State : States
diff --git a/src/Device/Primitive.hpp b/src/Device/Primitive.hpp
index a6aaa43..1e085f7 100644
--- a/src/Device/Primitive.hpp
+++ b/src/Device/Primitive.hpp
@@ -47,14 +47,7 @@
 
 		union
 		{
-			struct
-			{
-				PlaneEquation C[2][4];
-				PlaneEquation T[8][4];
-				PlaneEquation f;
-			};
-
-			PlaneEquation V[MAX_FRAGMENT_INPUTS][4];
+			PlaneEquation V[MAX_INTERFACE_COMPONENTS];
 		};
 
 		float area;
diff --git a/src/Device/QuadRasterizer.cpp b/src/Device/QuadRasterizer.cpp
index 770bf28..bfd87e1 100644
--- a/src/Device/QuadRasterizer.cpp
+++ b/src/Device/QuadRasterizer.cpp
@@ -238,19 +238,15 @@
 					Dw = *Pointer<Float4>(primitive + OFFSET(Primitive,w.C), 16) + yyyy * *Pointer<Float4>(primitive + OFFSET(Primitive,w.B), 16);
 				}
 
-				for(int interpolant = 0; interpolant < MAX_FRAGMENT_INPUTS; interpolant++)
+				for (int interpolant = 0; interpolant < MAX_INTERFACE_COMPONENTS; interpolant++)
 				{
-					for(int component = 0; component < 4; component++)
-					{
-						if(state.interpolant[interpolant].component & (1 << component))
-						{
-							Dv[interpolant][component] = *Pointer<Float4>(primitive + OFFSET(Primitive,V[interpolant][component].C), 16);
+					if (spirvShader->inputs[interpolant].Type == SpirvShader::ATTRIBTYPE_UNUSED)
+						continue;
 
-							if(!(state.interpolant[interpolant].flat & (1 << component)))
-							{
-								Dv[interpolant][component] += yyyy * *Pointer<Float4>(primitive + OFFSET(Primitive,V[interpolant][component].B), 16);
-							}
-						}
+					Dv[interpolant] = *Pointer<Float4>(primitive + OFFSET(Primitive, V[interpolant].C), 16);
+					if (!spirvShader->inputs[interpolant].Flat)
+					{
+						Dv[interpolant] += yyyy * *Pointer<Float4>(primitive + OFFSET(Primitive, V[interpolant].B), 16);
 					}
 				}
 
diff --git a/src/Device/QuadRasterizer.hpp b/src/Device/QuadRasterizer.hpp
index b04deb9..456887d 100644
--- a/src/Device/QuadRasterizer.hpp
+++ b/src/Device/QuadRasterizer.hpp
@@ -35,7 +35,7 @@
 
 		Float4 Dz[4];
 		Float4 Dw;
-		Float4 Dv[MAX_FRAGMENT_INPUTS][4];
+		Float4 Dv[MAX_INTERFACE_COMPONENTS];
 		Float4 Df;
 
 		UInt occlusion;