Commit 87a93308 by Geoff Lang

Move validation of ANGLE_instanced_arrays to the validation layer.

BUG=angle:520 Change-Id: Idb3c50235a7029e72c58bc202aba0cfab735202a Reviewed-on: https://chromium-review.googlesource.com/218510Reviewed-by: 's avatarShannon Woods <shannonwoods@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 61f54180
...@@ -1365,7 +1365,7 @@ void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei coun ...@@ -1365,7 +1365,7 @@ void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei coun
gl::Context *context = gl::getNonLostContext(); gl::Context *context = gl::getNonLostContext();
if (context) if (context)
{ {
if (!ValidateDrawArraysInstanced(context, mode, first, count, primcount)) if (!ValidateDrawArraysInstancedANGLE(context, mode, first, count, primcount))
{ {
return; return;
} }
...@@ -1401,7 +1401,7 @@ void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum t ...@@ -1401,7 +1401,7 @@ void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum t
if (context) if (context)
{ {
rx::RangeUI indexRange; rx::RangeUI indexRange;
if (!ValidateDrawElementsInstanced(context, mode, count, type, indices, primcount, &indexRange)) if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange))
{ {
return; return;
} }
......
...@@ -81,10 +81,9 @@ GLenum VertexDeclarationCache::applyDeclaration(IDirect3DDevice9 *device, Transl ...@@ -81,10 +81,9 @@ GLenum VertexDeclarationCache::applyDeclaration(IDirect3DDevice9 *device, Transl
} }
} }
if (indexedAttribute == gl::MAX_VERTEX_ATTRIBS) // The validation layer checks that there is at least one active attribute with a zero divisor as per
{ // the GL_ANGLE_instanced_arrays spec.
return GL_INVALID_OPERATION; ASSERT(indexedAttribute != gl::MAX_VERTEX_ATTRIBS);
}
} }
D3DCAPS9 caps; D3DCAPS9 caps;
......
...@@ -1560,6 +1560,39 @@ bool ValidateDrawArraysInstanced(Context *context, GLenum mode, GLint first, GLs ...@@ -1560,6 +1560,39 @@ bool ValidateDrawArraysInstanced(Context *context, GLenum mode, GLint first, GLs
return (primcount > 0); return (primcount > 0);
} }
static bool ValidateDrawInstancedANGLE(Context *context)
{
// Verify there is at least one active attribute with a divisor of zero
const gl::State& state = context->getState();
gl::ProgramBinary *programBinary = state.getCurrentProgramBinary();
const VertexArray *vao = state.getVertexArray();
for (int attributeIndex = 0; attributeIndex < MAX_VERTEX_ATTRIBS; attributeIndex++)
{
const VertexAttribute &attrib = vao->getVertexAttribute(attributeIndex);
bool active = (programBinary->getSemanticIndex(attributeIndex) != -1);
if (active && attrib.divisor == 0)
{
return true;
}
}
context->recordError(Error(GL_INVALID_OPERATION, "ANGLE_instanced_arrays requires that at least one active attribute"
"has a divisor of zero."));
return false;
}
bool ValidateDrawArraysInstancedANGLE(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount)
{
if (!ValidateDrawInstancedANGLE(context))
{
return false;
}
return ValidateDrawArraysInstanced(context, mode, first, count, primcount);
}
bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum type, bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum type,
const GLvoid* indices, GLsizei primcount, rx::RangeUI *indexRangeOut) const GLvoid* indices, GLsizei primcount, rx::RangeUI *indexRangeOut)
{ {
...@@ -1681,6 +1714,17 @@ bool ValidateDrawElementsInstanced(Context *context, ...@@ -1681,6 +1714,17 @@ bool ValidateDrawElementsInstanced(Context *context,
return (primcount > 0); return (primcount > 0);
} }
bool ValidateDrawElementsInstancedANGLE(Context *context, GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei primcount, rx::RangeUI *indexRangeOut)
{
if (!ValidateDrawInstancedANGLE(context))
{
return false;
}
return ValidateDrawElementsInstanced(context, mode, count, type, indices, primcount, indexRangeOut);
}
bool ValidateFramebufferTextureBase(Context *context, GLenum target, GLenum attachment, bool ValidateFramebufferTextureBase(Context *context, GLenum target, GLenum attachment,
GLuint texture, GLint level) GLuint texture, GLint level)
{ {
......
...@@ -66,12 +66,15 @@ bool ValidateCopyTexImageParametersBase(Context* context, GLenum target, GLint l ...@@ -66,12 +66,15 @@ bool ValidateCopyTexImageParametersBase(Context* context, GLenum target, GLint l
bool ValidateDrawArrays(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount); bool ValidateDrawArrays(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount);
bool ValidateDrawArraysInstanced(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount); bool ValidateDrawArraysInstanced(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount);
bool ValidateDrawArraysInstancedANGLE(Context *context, GLenum mode, GLint first, GLsizei count, GLsizei primcount);
bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum type, bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum type,
const GLvoid* indices, GLsizei primcount, rx::RangeUI *indexRangeOut); const GLvoid* indices, GLsizei primcount, rx::RangeUI *indexRangeOut);
bool ValidateDrawElementsInstanced(Context *context, GLenum mode, GLsizei count, GLenum type, bool ValidateDrawElementsInstanced(Context *context, GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei primcount, rx::RangeUI *indexRangeOut); const GLvoid *indices, GLsizei primcount, rx::RangeUI *indexRangeOut);
bool ValidateDrawElementsInstancedANGLE(Context *context, GLenum mode, GLsizei count, GLenum type,
const GLvoid *indices, GLsizei primcount, rx::RangeUI *indexRangeOut);
bool ValidateFramebufferTextureBase(Context *context, GLenum target, GLenum attachment, bool ValidateFramebufferTextureBase(Context *context, GLenum target, GLenum attachment,
GLuint texture, GLint level); GLuint texture, GLint level);
......
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