aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGeoff Lang <geofflang@chromium.org>2014-09-16 13:29:43 -0400
committerGeoff Lang <geofflang@chromium.org>2014-09-17 20:09:56 +0000
commit87a93308da237626325d13339565d7136125ed0d (patch)
tree528e3962b6ef4977b3f857e6789aa70d311c3c58 /src
parent61f541802f0aecd106f8feaf4ef6dd003cc4aee9 (diff)
downloadangle-87a93308da237626325d13339565d7136125ed0d.tar.gz
Move validation of ANGLE_instanced_arrays to the validation layer.
BUG=angle:520 Change-Id: Idb3c50235a7029e72c58bc202aba0cfab735202a Reviewed-on: https://chromium-review.googlesource.com/218510 Reviewed-by: Shannon Woods <shannonwoods@chromium.org> Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Diffstat (limited to 'src')
-rw-r--r--src/libGLESv2/libGLESv2.cpp4
-rw-r--r--src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.cpp7
-rw-r--r--src/libGLESv2/validationES.cpp44
-rw-r--r--src/libGLESv2/validationES.h3
4 files changed, 52 insertions, 6 deletions
diff --git a/src/libGLESv2/libGLESv2.cpp b/src/libGLESv2/libGLESv2.cpp
index d41d2c23..d373c0c5 100644
--- a/src/libGLESv2/libGLESv2.cpp
+++ b/src/libGLESv2/libGLESv2.cpp
@@ -1365,7 +1365,7 @@ void __stdcall glDrawArraysInstancedANGLE(GLenum mode, GLint first, GLsizei coun
gl::Context *context = gl::getNonLostContext();
if (context)
{
- if (!ValidateDrawArraysInstanced(context, mode, first, count, primcount))
+ if (!ValidateDrawArraysInstancedANGLE(context, mode, first, count, primcount))
{
return;
}
@@ -1401,7 +1401,7 @@ void __stdcall glDrawElementsInstancedANGLE(GLenum mode, GLsizei count, GLenum t
if (context)
{
rx::RangeUI indexRange;
- if (!ValidateDrawElementsInstanced(context, mode, count, type, indices, primcount, &indexRange))
+ if (!ValidateDrawElementsInstancedANGLE(context, mode, count, type, indices, primcount, &indexRange))
{
return;
}
diff --git a/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.cpp b/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.cpp
index 4c8d6dfb..d0d72c01 100644
--- a/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.cpp
+++ b/src/libGLESv2/renderer/d3d/d3d9/VertexDeclarationCache.cpp
@@ -81,10 +81,9 @@ GLenum VertexDeclarationCache::applyDeclaration(IDirect3DDevice9 *device, Transl
}
}
- if (indexedAttribute == gl::MAX_VERTEX_ATTRIBS)
- {
- return GL_INVALID_OPERATION;
- }
+ // The validation layer checks that there is at least one active attribute with a zero divisor as per
+ // the GL_ANGLE_instanced_arrays spec.
+ ASSERT(indexedAttribute != gl::MAX_VERTEX_ATTRIBS);
}
D3DCAPS9 caps;
diff --git a/src/libGLESv2/validationES.cpp b/src/libGLESv2/validationES.cpp
index 6a843dc8..9a5fa311 100644
--- a/src/libGLESv2/validationES.cpp
+++ b/src/libGLESv2/validationES.cpp
@@ -1560,6 +1560,39 @@ bool ValidateDrawArraysInstanced(Context *context, GLenum mode, GLint first, GLs
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,
const GLvoid* indices, GLsizei primcount, rx::RangeUI *indexRangeOut)
{
@@ -1681,6 +1714,17 @@ bool ValidateDrawElementsInstanced(Context *context,
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,
GLuint texture, GLint level)
{
diff --git a/src/libGLESv2/validationES.h b/src/libGLESv2/validationES.h
index 30a9494d..1fdb633c 100644
--- a/src/libGLESv2/validationES.h
+++ b/src/libGLESv2/validationES.h
@@ -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 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,
const GLvoid* indices, GLsizei primcount, rx::RangeUI *indexRangeOut);
bool ValidateDrawElementsInstanced(Context *context, GLenum mode, GLsizei count, GLenum type,
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,
GLuint texture, GLint level);