Commit f5c88e7e by Jamie Madill Committed by Commit Bot

Refactor and inline DrawElements validation.

This moves ValidateDrawBase into a common inline function. It also moves some checks in ValidateDrawElementsCommon into ValidateDrawElementsBase. "Base" is called from DrawElementsIndirect while "Common" is only called from non-indirect entry points. But this improves conformance because the missing checks in "Base" apply to DrawIndirect as well. In a follow-up patch many checks in "Base" will be cached into a single value. Much like what we did for ValidateDrawBase. Also inlines ValidateDrawElements which just calls through to "Common". Bug: angleproject:2966 Change-Id: Ibe0c5db25f403dd52a50dc73373ebb50cedad003 Reviewed-on: https://chromium-review.googlesource.com/c/1357147 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent 149eb33b
...@@ -286,7 +286,38 @@ bool ValidateCopyTexImageParametersBase(Context *context, ...@@ -286,7 +286,38 @@ bool ValidateCopyTexImageParametersBase(Context *context,
GLint border, GLint border,
Format *textureFormatOut); Format *textureFormatOut);
bool ValidateDrawBase(Context *context, PrimitiveMode mode, GLsizei count); bool ValidateDrawMode(Context *context, PrimitiveMode mode);
ANGLE_INLINE bool ValidateDrawBase(Context *context, PrimitiveMode mode, GLsizei count)
{
if (!context->getStateCache().isValidDrawMode(mode))
{
return ValidateDrawMode(context, mode);
}
if (count < 0)
{
context->validationError(GL_INVALID_VALUE, err::kNegativeCount);
return false;
}
intptr_t drawStatesError = context->getStateCache().getBasicDrawStatesError(context);
if (drawStatesError)
{
const char *errorMessage = reinterpret_cast<const char *>(drawStatesError);
// All errors from ValidateDrawStates should return INVALID_OPERATION except Framebuffer
// Incomplete.
GLenum errorCode =
(errorMessage == err::kDrawFramebufferIncomplete ? GL_INVALID_FRAMEBUFFER_OPERATION
: GL_INVALID_OPERATION);
context->validationError(errorCode, errorMessage);
return false;
}
return true;
}
bool ValidateDrawArraysCommon(Context *context, bool ValidateDrawArraysCommon(Context *context,
PrimitiveMode mode, PrimitiveMode mode,
GLint first, GLint first,
......
...@@ -5771,15 +5771,6 @@ bool ValidateViewport(Context *context, GLint x, GLint y, GLsizei width, GLsizei ...@@ -5771,15 +5771,6 @@ bool ValidateViewport(Context *context, GLint x, GLint y, GLsizei width, GLsizei
return true; return true;
} }
bool ValidateDrawElements(Context *context,
PrimitiveMode mode,
GLsizei count,
DrawElementsType type,
const void *indices)
{
return ValidateDrawElementsCommon(context, mode, count, type, indices, 1);
}
bool ValidateGetFramebufferAttachmentParameteriv(Context *context, bool ValidateGetFramebufferAttachmentParameteriv(Context *context,
GLenum target, GLenum target,
GLenum attachment, GLenum attachment,
......
...@@ -45,6 +45,15 @@ ANGLE_INLINE bool ValidateBindBuffer(Context *context, BufferBinding target, GLu ...@@ -45,6 +45,15 @@ ANGLE_INLINE bool ValidateBindBuffer(Context *context, BufferBinding target, GLu
return true; return true;
} }
ANGLE_INLINE bool ValidateDrawElements(Context *context,
PrimitiveMode mode,
GLsizei count,
DrawElementsType type,
const void *indices)
{
return ValidateDrawElementsCommon(context, mode, count, type, indices, 1);
}
} // 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