Added validation to shader related functions

- Added uniform block binding validation
- Disallowed setting int uniforms from unsigned
  int specific functions and vice versa.
- Moved early returns from uniform related
  functions further down the functions to allow
  gl errors to be returned
- Added active transform feedback checks
- Fixed some gl error return codes.

Fixes most failures in:
dEQP-GLES3.functional.negative_api.shader*

Change-Id: Id9f914a09dd89fea61728725f8bd828dc7b3f81b
Reviewed-on: https://swiftshader-review.googlesource.com/14128
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/OpenGL/libGLESv2/libGLESv2.cpp b/src/OpenGL/libGLESv2/libGLESv2.cpp
index c560600..5f14e9c 100644
--- a/src/OpenGL/libGLESv2/libGLESv2.cpp
+++ b/src/OpenGL/libGLESv2/libGLESv2.cpp
@@ -4532,6 +4532,15 @@
 			}
 		}
 
+		if(programObject == context->getCurrentProgram())
+		{
+			es2::TransformFeedback* transformFeedback = context->getTransformFeedback();
+			if(transformFeedback && transformFeedback->isActive())
+			{
+				return error(GL_INVALID_OPERATION);
+			}
+		}
+
 		programObject->link();
 	}
 }
@@ -5563,11 +5572,6 @@
 		return error(GL_INVALID_VALUE);
 	}
 
-	if(location == -1)
-	{
-		return;
-	}
-
 	es2::Context *context = es2::getContext();
 
 	if(context)
@@ -5579,6 +5583,11 @@
 			return error(GL_INVALID_OPERATION);
 		}
 
+		if(location == -1)
+		{
+			return;
+		}
+
 		if(!program->setUniform1fv(location, count, v))
 		{
 			return error(GL_INVALID_OPERATION);
@@ -5600,11 +5609,6 @@
 		return error(GL_INVALID_VALUE);
 	}
 
-	if(location == -1)
-	{
-		return;
-	}
-
 	es2::Context *context = es2::getContext();
 
 	if(context)
@@ -5616,6 +5620,11 @@
 			return error(GL_INVALID_OPERATION);
 		}
 
+		if(location == -1)
+		{
+			return;
+		}
+
 		if(!program->setUniform1iv(location, count, v))
 		{
 			return error(GL_INVALID_OPERATION);
@@ -5639,11 +5648,6 @@
 		return error(GL_INVALID_VALUE);
 	}
 
-	if(location == -1)
-	{
-		return;
-	}
-
 	es2::Context *context = es2::getContext();
 
 	if(context)
@@ -5655,6 +5659,11 @@
 			return error(GL_INVALID_OPERATION);
 		}
 
+		if(location == -1)
+		{
+			return;
+		}
+
 		if(!program->setUniform2fv(location, count, v))
 		{
 			return error(GL_INVALID_OPERATION);
@@ -5678,11 +5687,6 @@
 		return error(GL_INVALID_VALUE);
 	}
 
-	if(location == -1)
-	{
-		return;
-	}
-
 	es2::Context *context = es2::getContext();
 
 	if(context)
@@ -5694,6 +5698,11 @@
 			return error(GL_INVALID_OPERATION);
 		}
 
+		if(location == -1)
+		{
+			return;
+		}
+
 		if(!program->setUniform2iv(location, count, v))
 		{
 			return error(GL_INVALID_OPERATION);
@@ -5717,11 +5726,6 @@
 		return error(GL_INVALID_VALUE);
 	}
 
-	if(location == -1)
-	{
-		return;
-	}
-
 	es2::Context *context = es2::getContext();
 
 	if(context)
@@ -5733,6 +5737,11 @@
 			return error(GL_INVALID_OPERATION);
 		}
 
+		if(location == -1)
+		{
+			return;
+		}
+
 		if(!program->setUniform3fv(location, count, v))
 		{
 			return error(GL_INVALID_OPERATION);
@@ -5756,11 +5765,6 @@
 		return error(GL_INVALID_VALUE);
 	}
 
-	if(location == -1)
-	{
-		return;
-	}
-
 	es2::Context *context = es2::getContext();
 
 	if(context)
@@ -5772,6 +5776,11 @@
 			return error(GL_INVALID_OPERATION);
 		}
 
+		if(location == -1)
+		{
+			return;
+		}
+
 		if(!program->setUniform3iv(location, count, v))
 		{
 			return error(GL_INVALID_OPERATION);
@@ -5795,11 +5804,6 @@
 		return error(GL_INVALID_VALUE);
 	}
 
-	if(location == -1)
-	{
-		return;
-	}
-
 	es2::Context *context = es2::getContext();
 
 	if(context)
@@ -5811,6 +5815,11 @@
 			return error(GL_INVALID_OPERATION);
 		}
 
+		if(location == -1)
+		{
+			return;
+		}
+
 		if(!program->setUniform4fv(location, count, v))
 		{
 			return error(GL_INVALID_OPERATION);
@@ -5834,11 +5843,6 @@
 		return error(GL_INVALID_VALUE);
 	}
 
-	if(location == -1)
-	{
-		return;
-	}
-
 	es2::Context *context = es2::getContext();
 
 	if(context)
@@ -5850,6 +5854,11 @@
 			return error(GL_INVALID_OPERATION);
 		}
 
+		if(location == -1)
+		{
+			return;
+		}
+
 		if(!program->setUniform4iv(location, count, v))
 		{
 			return error(GL_INVALID_OPERATION);
@@ -5867,11 +5876,6 @@
 		return error(GL_INVALID_VALUE);
 	}
 
-	if(location == -1)
-	{
-		return;
-	}
-
 	es2::Context *context = es2::getContext();
 
 	if(context)
@@ -5888,6 +5892,11 @@
 			return error(GL_INVALID_OPERATION);
 		}
 
+		if(location == -1)
+		{
+			return;
+		}
+
 		if(!program->setUniformMatrix2fv(location, count, transpose, value))
 		{
 			return error(GL_INVALID_OPERATION);
@@ -5905,11 +5914,6 @@
 		return error(GL_INVALID_VALUE);
 	}
 
-	if(location == -1)
-	{
-		return;
-	}
-
 	es2::Context *context = es2::getContext();
 
 	if(context)
@@ -5926,6 +5930,11 @@
 			return error(GL_INVALID_OPERATION);
 		}
 
+		if(location == -1)
+		{
+			return;
+		}
+
 		if(!program->setUniformMatrix3fv(location, count, transpose, value))
 		{
 			return error(GL_INVALID_OPERATION);
@@ -5943,11 +5952,6 @@
 		return error(GL_INVALID_VALUE);
 	}
 
-	if(location == -1)
-	{
-		return;
-	}
-
 	es2::Context *context = es2::getContext();
 
 	if(context)
@@ -5964,6 +5968,11 @@
 			return error(GL_INVALID_OPERATION);
 		}
 
+		if(location == -1)
+		{
+			return;
+		}
+
 		if(!program->setUniformMatrix4fv(location, count, transpose, value))
 		{
 			return error(GL_INVALID_OPERATION);
@@ -5979,6 +5988,12 @@
 
 	if(context)
 	{
+		es2::TransformFeedback* transformFeedback = context->getTransformFeedback();
+		if(transformFeedback && transformFeedback->isActive() && !transformFeedback->isPaused())
+		{
+			return error(GL_INVALID_OPERATION);
+		}
+
 		es2::Program *programObject = context->getProgram(program);
 
 		if(!programObject && program != 0)