Refactor some entry point stuff.
BUG=angleproject:747
Change-Id: I80634b5e6de8bae1433c49a56a92d3b19c24e11d
Reviewed-on: https://chromium-review.googlesource.com/395568
Commit-Queue: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES2.cpp b/src/libANGLE/validationES2.cpp
index b98f6b4..28b4f1c 100644
--- a/src/libANGLE/validationES2.cpp
+++ b/src/libANGLE/validationES2.cpp
@@ -10,19 +10,19 @@
#include <cstdint>
-#include "libANGLE/validationES.h"
-#include "libANGLE/validationES3.h"
-#include "libANGLE/Context.h"
-#include "libANGLE/Texture.h"
-#include "libANGLE/Framebuffer.h"
-#include "libANGLE/Renderbuffer.h"
-#include "libANGLE/formatutils.h"
-#include "libANGLE/FramebufferAttachment.h"
-#include "libANGLE/Uniform.h"
-
#include "common/mathutil.h"
#include "common/string_utils.h"
#include "common/utilities.h"
+#include "libANGLE/Context.h"
+#include "libANGLE/Texture.h"
+#include "libANGLE/Framebuffer.h"
+#include "libANGLE/FramebufferAttachment.h"
+#include "libANGLE/Renderbuffer.h"
+#include "libANGLE/Shader.h"
+#include "libANGLE/Uniform.h"
+#include "libANGLE/formatutils.h"
+#include "libANGLE/validationES.h"
+#include "libANGLE/validationES3.h"
namespace gl
{
@@ -3526,4 +3526,67 @@
return true;
}
+bool ValidateActiveTexture(ValidationContext *context, GLenum texture)
+{
+ if (texture < GL_TEXTURE0 ||
+ texture > GL_TEXTURE0 + context->getCaps().maxCombinedTextureImageUnits - 1)
+ {
+ context->handleError(Error(GL_INVALID_ENUM));
+ return false;
+ }
+
+ return true;
+}
+
+bool ValidateAttachShader(ValidationContext *context, GLuint program, GLuint shader)
+{
+ Program *programObject = GetValidProgram(context, program);
+ if (!programObject)
+ {
+ return false;
+ }
+
+ Shader *shaderObject = GetValidShader(context, shader);
+ if (!shaderObject)
+ {
+ return false;
+ }
+
+ switch (shaderObject->getType())
+ {
+ case GL_VERTEX_SHADER:
+ {
+ if (programObject->getAttachedVertexShader())
+ {
+ context->handleError(Error(GL_INVALID_OPERATION));
+ return false;
+ }
+ break;
+ }
+ case GL_FRAGMENT_SHADER:
+ {
+ if (programObject->getAttachedFragmentShader())
+ {
+ context->handleError(Error(GL_INVALID_OPERATION));
+ return false;
+ }
+ break;
+ }
+ case GL_COMPUTE_SHADER:
+ {
+ if (programObject->getAttachedComputeShader())
+ {
+ context->handleError(Error(GL_INVALID_OPERATION));
+ return false;
+ }
+ break;
+ }
+ default:
+ UNREACHABLE();
+ break;
+ }
+
+ return true;
+}
+
} // namespace gl