glGetFragDataLocation implementation

Implemented glGetFragDataLocation. There's very little coverage for
this function in dEQP, but the one test that uses it passes.

Change-Id: I6cfc93d7eaad54f23c922e45dafee9cba3401c83
Note: Chromium's ES3 path requires this function to be implemented.
Reviewed-on: https://swiftshader-review.googlesource.com/11728
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/OpenGL/libGLESv2/Program.cpp b/src/OpenGL/libGLESv2/Program.cpp
index 24d1f3c..7eda6f5 100644
--- a/src/OpenGL/libGLESv2/Program.cpp
+++ b/src/OpenGL/libGLESv2/Program.cpp
@@ -254,6 +254,27 @@
 		return vertexBinary;
 	}
 
+	GLint Program::getFragDataLocation(const GLchar *name)
+	{
+		if(name && linked)
+		{
+			std::string baseName(name);
+			unsigned int subscript = GL_INVALID_INDEX;
+			baseName = ParseUniformName(baseName, &subscript);
+			for(glsl::VaryingList::iterator input = fragmentShader->varyings.begin(); input != fragmentShader->varyings.end(); ++input)
+			{
+				if(input->name == baseName)
+				{
+					int rowCount = VariableRowCount(input->type);
+					int colCount = VariableColumnCount(input->type);
+					return (subscript == GL_INVALID_INDEX) ? input->reg : input->reg + (rowCount > 1 ? colCount * subscript : subscript);
+				}
+			}
+		}
+
+		return -1;
+	}
+
 	void Program::bindAttributeLocation(GLuint index, const char *name)
 	{
 		if(index < MAX_VERTEX_ATTRIBS)