Commit 1aeb1314 by Jamie Madill

Move draw call primitive type check to the API.

A part of a larger refactoring to clean up the draw call validation. BUG=angle:571 Change-Id: I0b220d68c04524a81ca11dc58e10c90e458cabde Reviewed-on: https://chromium-review.googlesource.com/203771Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org>
parent 9efa581d
...@@ -793,7 +793,8 @@ bool Renderer11::applyPrimitiveType(GLenum mode, GLsizei count) ...@@ -793,7 +793,8 @@ bool Renderer11::applyPrimitiveType(GLenum mode, GLsizei count)
// emulate fans via rewriting index buffer // emulate fans via rewriting index buffer
case GL_TRIANGLE_FAN: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; minCount = 3; break; case GL_TRIANGLE_FAN: primitiveTopology = D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; minCount = 3; break;
default: default:
return gl::error(GL_INVALID_ENUM, false); UNREACHABLE();
return false;
} }
if (primitiveTopology != mCurrentPrimitiveTopology) if (primitiveTopology != mCurrentPrimitiveTopology)
......
...@@ -1094,7 +1094,8 @@ bool Renderer9::applyPrimitiveType(GLenum mode, GLsizei count) ...@@ -1094,7 +1094,8 @@ bool Renderer9::applyPrimitiveType(GLenum mode, GLsizei count)
mPrimitiveCount = count - 2; mPrimitiveCount = count - 2;
break; break;
default: default:
return gl::error(GL_INVALID_ENUM, false); UNREACHABLE();
return false;
} }
return mPrimitiveCount > 0; return mPrimitiveCount > 0;
......
...@@ -1290,8 +1290,22 @@ bool ValidateCopyTexImageParametersBase(gl::Context* context, GLenum target, GLi ...@@ -1290,8 +1290,22 @@ bool ValidateCopyTexImageParametersBase(gl::Context* context, GLenum target, GLi
return true; return true;
} }
static bool ValidateDrawBase(const gl::Context *context, GLsizei count) static bool ValidateDrawBase(const gl::Context *context, GLenum mode, GLsizei count)
{ {
switch (mode)
{
case GL_POINTS:
case GL_LINES:
case GL_LINE_LOOP:
case GL_LINE_STRIP:
case GL_TRIANGLES:
case GL_TRIANGLE_STRIP:
case GL_TRIANGLE_FAN:
break;
default:
return gl::error(GL_INVALID_ENUM, false);
}
if (count < 0) if (count < 0)
{ {
return gl::error(GL_INVALID_VALUE, false); return gl::error(GL_INVALID_VALUE, false);
...@@ -1347,7 +1361,7 @@ bool ValidateDrawArrays(const gl::Context *context, GLenum mode, GLint first, GL ...@@ -1347,7 +1361,7 @@ bool ValidateDrawArrays(const gl::Context *context, GLenum mode, GLint first, GL
return gl::error(GL_INVALID_OPERATION, false); return gl::error(GL_INVALID_OPERATION, false);
} }
if (!ValidateDrawBase(context, count)) if (!ValidateDrawBase(context, mode, count))
{ {
return false; return false;
} }
...@@ -1408,7 +1422,7 @@ bool ValidateDrawElements(const gl::Context *context, GLenum mode, GLsizei count ...@@ -1408,7 +1422,7 @@ bool ValidateDrawElements(const gl::Context *context, GLenum mode, GLsizei count
return gl::error(GL_INVALID_OPERATION, false); return gl::error(GL_INVALID_OPERATION, false);
} }
if (!ValidateDrawBase(context, count)) if (!ValidateDrawBase(context, mode, count))
{ {
return false; return false;
} }
......
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