Implement flat interpolation qualifier support.

By default vertex shader outputs/fragment shader inputs are
smoothly interpolated. The 'flat' keyword can be used to change
the interpolation to "flat", which basically means that no
interpolation is performed. "flat" is the only interpolation
qualifier accepted for integer types.

This change fixes all shaders/precision dEQP tests as well as a
few fragment output integer format types related tests.

Change-Id: Ic64b0ec40c705d885c255b3b671cf7460965dfee
Reviewed-on: https://swiftshader-review.googlesource.com/5390
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/Renderer/SetupProcessor.cpp b/src/Renderer/SetupProcessor.cpp
index 9075719..750846f 100644
--- a/src/Renderer/SetupProcessor.cpp
+++ b/src/Renderer/SetupProcessor.cpp
@@ -129,13 +129,14 @@
 				for(int component = 0; component < 4; component++)
 				{
 					int project = context->isProjectionComponent(interpolant - 2, component) ? 1 : 0;
+					const Shader::Semantic& semantic = context->pixelShader->semantic[interpolant][component - project];
 
-					if(context->pixelShader->semantic[interpolant][component - project].active())
+					if(semantic.active())
 					{
 						int input = interpolant;
 						for(int i = 0; i < MAX_VERTEX_OUTPUTS; i++)
 						{
-							if(context->pixelShader->semantic[interpolant][component - project] == context->vertexShader->output[i][component - project])
+							if(semantic == context->vertexShader->output[i][component - project])
 							{
 								input = i;
 								break;
@@ -144,10 +145,10 @@
 
 						bool flat = point;
 
-						switch(context->pixelShader->semantic[interpolant][component - project].usage)
+						switch(semantic.usage)
 						{
-						case Shader::USAGE_TEXCOORD: flat = point && !sprite; break;
-						case Shader::USAGE_COLOR:    flat = flatShading;      break;
+						case Shader::USAGE_TEXCOORD: flat = point && !sprite;             break;
+						case Shader::USAGE_COLOR:    flat = semantic.flat || flatShading; break;
 						}
 
 						state.gradient[interpolant][component].attribute = input;
@@ -162,19 +163,19 @@
 			{
 				for(int component = 0; component < 4; component++)
 				{
-					int index = context->pixelShader->semantic[interpolant][component].index;
+					const Shader::Semantic& semantic = context->pixelShader->semantic[interpolant][component];
 
-					switch(context->pixelShader->semantic[interpolant][component].usage)
+					switch(semantic.usage)
 					{
 					case 0xFF:
 						break;
 					case Shader::USAGE_TEXCOORD:
-						state.gradient[interpolant][component].attribute = T0 + index;
-						state.gradient[interpolant][component].flat = point && !sprite;
+						state.gradient[interpolant][component].attribute = T0 + semantic.index;
+						state.gradient[interpolant][component].flat = semantic.flat || (point && !sprite);
 						break;
 					case Shader::USAGE_COLOR:
-						state.gradient[interpolant][component].attribute = C0 + index;
-						state.gradient[interpolant][component].flat = flatShading;
+						state.gradient[interpolant][component].attribute = C0 + semantic.index;
+						state.gradient[interpolant][component].flat = semantic.flat || flatShading;
 						break;
 					default:
 						ASSERT(false);