Commit a139f01a by Jamie Madill Committed by Commit Bot

Inline ValidateBindBuffer.

This method is only called in one place. Inlining reduces the need to make a jump and push/pop variables from the stack. It also adds a specialized error handler for validation errors. This reduces the amount of code generated for errors. The prior method generates a lot of code when dealing with string streams. Improves performance of the binding performance test. Bug: angleproject:2763 Change-Id: I52af7046b398072975bf5bda583efac9a9b9a8cb Reviewed-on: https://chromium-review.googlesource.com/c/1270219Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 1c7f08c3
...@@ -2628,6 +2628,11 @@ void Context::handleError(GLenum errorCode, ...@@ -2628,6 +2628,11 @@ void Context::handleError(GLenum errorCode,
mErrors.handleError(errorCode, message, file, function, line); mErrors.handleError(errorCode, message, file, function, line);
} }
void Context::validationError(GLenum errorCode, const char *message)
{
mErrors.validationError(errorCode, message);
}
// Get one of the recorded errors and clear its flag, if any. // Get one of the recorded errors and clear its flag, if any.
// [OpenGL ES 2.0.24] section 2.5 page 13. // [OpenGL ES 2.0.24] section 2.5 page 13.
GLenum Context::getError() GLenum Context::getError()
...@@ -7977,6 +7982,11 @@ void ErrorSet::handleError(GLenum errorCode, ...@@ -7977,6 +7982,11 @@ void ErrorSet::handleError(GLenum errorCode,
handleError(gl::Error(errorCode, errorCode, errorStream.str())); handleError(gl::Error(errorCode, errorCode, errorStream.str()));
} }
void ErrorSet::validationError(GLenum errorCode, const char *message)
{
handleError(gl::Error(errorCode, message));
}
bool ErrorSet::empty() const bool ErrorSet::empty() const
{ {
return mErrors.empty(); return mErrors.empty();
......
...@@ -81,6 +81,8 @@ class ErrorSet : angle::NonCopyable ...@@ -81,6 +81,8 @@ class ErrorSet : angle::NonCopyable
const char *function, const char *function,
unsigned int line); unsigned int line);
void validationError(GLenum errorCode, const char *message);
private: private:
Context *mContext; Context *mContext;
...@@ -1576,6 +1578,8 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl ...@@ -1576,6 +1578,8 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
const char *function, const char *function,
unsigned int line); unsigned int line);
void validationError(GLenum errorCode, const char *message);
GLenum getError(); GLenum getError();
void markContextLost(); void markContextLost();
...@@ -1655,7 +1659,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl ...@@ -1655,7 +1659,7 @@ class Context final : public egl::LabeledObject, angle::NonCopyable, public angl
return mState.mTextures->isHandleGenerated(texture); return mState.mTextures->isHandleGenerated(texture);
} }
bool isBufferGenerated(GLuint buffer) const ANGLE_INLINE bool isBufferGenerated(GLuint buffer) const
{ {
return mState.mBuffers->isHandleGenerated(buffer); return mState.mBuffers->isHandleGenerated(buffer);
} }
......
...@@ -4512,36 +4512,18 @@ bool ValidateBindAttribLocation(Context *context, GLuint program, GLuint index, ...@@ -4512,36 +4512,18 @@ bool ValidateBindAttribLocation(Context *context, GLuint program, GLuint index,
return GetValidProgram(context, program) != nullptr; return GetValidProgram(context, program) != nullptr;
} }
bool ValidateBindBuffer(Context *context, BufferBinding target, GLuint buffer)
{
if (!context->isValidBufferBinding(target))
{
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidBufferTypes);
return false;
}
if (!context->getGLState().isBindGeneratesResourceEnabled() &&
!context->isBufferGenerated(buffer))
{
ANGLE_VALIDATION_ERR(context, InvalidOperation(), ObjectNotGenerated);
return false;
}
return true;
}
bool ValidateBindFramebuffer(Context *context, GLenum target, GLuint framebuffer) bool ValidateBindFramebuffer(Context *context, GLenum target, GLuint framebuffer)
{ {
if (!ValidFramebufferTarget(context, target)) if (!ValidFramebufferTarget(context, target))
{ {
ANGLE_VALIDATION_ERR(context, InvalidEnum(), InvalidFramebufferTarget); context->validationError(GL_INVALID_ENUM, kErrorInvalidFramebufferTarget);
return false; return false;
} }
if (!context->getGLState().isBindGeneratesResourceEnabled() && if (!context->getGLState().isBindGeneratesResourceEnabled() &&
!context->isFramebufferGenerated(framebuffer)) !context->isFramebufferGenerated(framebuffer))
{ {
ANGLE_VALIDATION_ERR(context, InvalidOperation(), ObjectNotGenerated); context->validationError(GL_INVALID_OPERATION, kErrorObjectNotGenerated);
return false; return false;
} }
......
...@@ -722,11 +722,34 @@ bool ValidateTexStorage3DEXT(Context *context, ...@@ -722,11 +722,34 @@ bool ValidateTexStorage3DEXT(Context *context,
GLsizei height, GLsizei height,
GLsizei depth); GLsizei depth);
bool ValidateMaxShaderCompilerThreadsKHR(Context *context, GLuint count); bool ValidateMaxShaderCompilerThreadsKHR(Context *context, GLuint count);
} // namespace gl
#include "libANGLE/ErrorStrings.h"
namespace gl
{
ANGLE_INLINE bool ValidateUniform2f(Context *context, GLint location, GLfloat x, GLfloat y) ANGLE_INLINE bool ValidateUniform2f(Context *context, GLint location, GLfloat x, GLfloat y)
{ {
return ValidateUniform(context, GL_FLOAT_VEC2, location, 1); return ValidateUniform(context, GL_FLOAT_VEC2, location, 1);
} }
ANGLE_INLINE bool ValidateBindBuffer(Context *context, BufferBinding target, GLuint buffer)
{
if (!context->isValidBufferBinding(target))
{
context->validationError(GL_INVALID_ENUM, kErrorInvalidBufferTypes);
return false;
}
if (!context->getGLState().isBindGeneratesResourceEnabled() &&
!context->isBufferGenerated(buffer))
{
context->validationError(GL_INVALID_OPERATION, kErrorObjectNotGenerated);
return false;
}
return true;
}
} // namespace gl } // namespace gl
#endif // LIBANGLE_VALIDATION_ES2_H_ #endif // LIBANGLE_VALIDATION_ES2_H_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment