Revert "Move more draw call validation to the API."
BUG=390412
This reverts commit 9efa581d0e8f251b88f5a2f432ddb20655036c77.
Conflicts:
src/libGLESv2/validationES.cpp
Change-Id: I78457e1dfec8b75fecef8dc40c549adbde680a2a
Reviewed-on: https://chromium-review.googlesource.com/206340
Reviewed-by: Brandon Jones <bajones@chromium.org>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Tested-by: Shannon Woods <shannonwoods@chromium.org>
diff --git a/src/libGLESv2/Context.cpp b/src/libGLESv2/Context.cpp
index 34d6a24..26451fa 100644
--- a/src/libGLESv2/Context.cpp
+++ b/src/libGLESv2/Context.cpp
@@ -1354,11 +1354,6 @@
}
-GLuint Context::getCurrentProgram() const
-{
- return mState.currentProgram;
-}
-
void Context::bindTransformFeedback(GLuint transformFeedback)
{
TransformFeedback *transformFeedbackObject = getTransformFeedback(transformFeedback);
@@ -1502,7 +1497,7 @@
return getCurrentVertexArray()->getElementArrayBuffer();
}
-ProgramBinary *Context::getCurrentProgramBinary() const
+ProgramBinary *Context::getCurrentProgramBinary()
{
return mCurrentProgramBinary.get();
}
@@ -2852,7 +2847,10 @@
void Context::drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instances)
{
- ASSERT(mState.currentProgram);
+ if (!mState.currentProgram)
+ {
+ return gl::error(GL_INVALID_OPERATION);
+ }
ProgramBinary *programBinary = getCurrentProgramBinary();
programBinary->applyUniforms();
@@ -2903,6 +2901,11 @@
return;
}
+ if (!programBinary->validateSamplers(NULL))
+ {
+ return gl::error(GL_INVALID_OPERATION);
+ }
+
if (!skipDraw(mode))
{
mRenderer->drawArrays(mode, count, instances, transformFeedbackActive);
@@ -2916,7 +2919,16 @@
void Context::drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instances)
{
- ASSERT(mState.currentProgram);
+ if (!mState.currentProgram)
+ {
+ return gl::error(GL_INVALID_OPERATION);
+ }
+
+ VertexArray *vao = getCurrentVertexArray();
+ if (!indices && !vao->getElementArrayBuffer())
+ {
+ return gl::error(GL_INVALID_OPERATION);
+ }
ProgramBinary *programBinary = getCurrentProgramBinary();
programBinary->applyUniforms();
@@ -2946,7 +2958,6 @@
applyState(mode);
- VertexArray *vao = getCurrentVertexArray();
rx::TranslatedIndexData indexInfo;
GLenum err = mRenderer->applyIndexBuffer(indices, vao->getElementArrayBuffer(), count, mode, type, &indexInfo);
if (err != GL_NO_ERROR)
@@ -2979,6 +2990,11 @@
return;
}
+ if (!programBinary->validateSamplers(NULL))
+ {
+ return gl::error(GL_INVALID_OPERATION);
+ }
+
if (!skipDraw(mode))
{
mRenderer->drawElements(mode, count, type, indices, vao->getElementArrayBuffer(), indexInfo, instances);
diff --git a/src/libGLESv2/Context.h b/src/libGLESv2/Context.h
index cc86603..6942d5b 100644
--- a/src/libGLESv2/Context.h
+++ b/src/libGLESv2/Context.h
@@ -306,7 +306,6 @@
void useProgram(GLuint program);
void linkProgram(GLuint program);
void setProgramBinary(GLuint program, const void *binary, GLint length);
- GLuint getCurrentProgram() const;
void bindTransformFeedback(GLuint transformFeedback);
void beginQuery(GLenum target, GLuint query);
@@ -342,7 +341,7 @@
Buffer *getTargetBuffer(GLenum target) const;
Buffer *getArrayBuffer();
Buffer *getElementArrayBuffer() const;
- ProgramBinary *getCurrentProgramBinary() const;
+ ProgramBinary *getCurrentProgramBinary();
Texture *getTargetTexture(GLenum target) const;
Texture2D *getTexture2D() const;
diff --git a/src/libGLESv2/validationES.cpp b/src/libGLESv2/validationES.cpp
index 93dd000..ec2a6b6 100644
--- a/src/libGLESv2/validationES.cpp
+++ b/src/libGLESv2/validationES.cpp
@@ -19,7 +19,6 @@
#include "libGLESv2/Query.h"
#include "libGLESv2/ProgramBinary.h"
#include "libGLESv2/TransformFeedback.h"
-#include "libGLESv2/VertexArray.h"
#include "common/mathutil.h"
#include "common/utilities.h"
@@ -1327,17 +1326,6 @@
return gl::error(GL_INVALID_OPERATION, false);
}
- if (!context->getCurrentProgram())
- {
- return gl::error(GL_INVALID_OPERATION, false);
- }
-
- gl::ProgramBinary *programBinary = context->getCurrentProgramBinary();
- if (!programBinary->validateSamplers(NULL))
- {
- return gl::error(GL_INVALID_OPERATION, false);
- }
-
const gl::Framebuffer *fbo = context->getDrawFramebuffer();
if (!fbo || fbo->completeness() != GL_FRAMEBUFFER_COMPLETE)
{
@@ -1420,12 +1408,6 @@
return gl::error(GL_INVALID_OPERATION, false);
}
- gl::VertexArray *vao = context->getCurrentVertexArray();
- if (!indices && !vao->getElementArrayBuffer())
- {
- return gl::error(GL_INVALID_OPERATION, false);
- }
-
if (!ValidateDrawBase(context, mode, count))
{
return false;