Bug 1326517 - Allow clearing to null with VertexAttribPointer. - r=kvark
MozReview-Commit-ID: Ai5ksUAyG4q
--- a/dom/canvas/WebGLContextValidate.cpp
+++ b/dom/canvas/WebGLContextValidate.cpp
@@ -339,18 +339,20 @@ WebGLContext::ValidateAttribIndex(GLuint
}
bool
WebGLContext::ValidateAttribPointer(bool integerMode, GLuint index, GLint size, GLenum type,
WebGLboolean normalized, GLsizei stride,
WebGLintptr byteOffset, const char* info)
{
WebGLBuffer* buffer = mBoundArrayBuffer;
- if (!buffer) {
- ErrorInvalidOperation("%s: must have valid GL_ARRAY_BUFFER binding", info);
+ if (!buffer && byteOffset) {
+ ErrorInvalidOperation("%s: When GL_ARRAY_BUFFER_BINDING is null, `byteOffset`"
+ " must be zero.",
+ info);
return false;
}
uint32_t requiredAlignment = 0;
if (!ValidateAttribPointerType(integerMode, type, &requiredAlignment, info))
return false;
// requiredAlignment should always be a power of two
--- a/dom/canvas/WebGLContextVertices.cpp
+++ b/dom/canvas/WebGLContextVertices.cpp
@@ -300,21 +300,16 @@ WebGLContext::VertexAttribPointer(GLuint
if (!ValidateAttribPointer(false, index, size, type, normalized, stride, byteOffset, "vertexAttribPointer"))
return;
MOZ_ASSERT(mBoundVertexArray);
InvalidateBufferFetching();
- /* XXX make work with bufferSubData & heterogeneous types
- if (type != mBoundArrayBuffer->GLType())
- return ErrorInvalidOperation("vertexAttribPointer: type must match bound VBO type: %d != %d", type, mBoundArrayBuffer->GLType());
- */
-
MakeContextCurrent();
gl->fVertexAttribPointer(index, size, type, normalized, stride,
reinterpret_cast<void*>(byteOffset));
WebGLVertexAttribData& vd = mBoundVertexArray->mAttribs[index];
const bool integerFunc = false;
vd.VertexAttribPointer(integerFunc, mBoundArrayBuffer, size, type, normalized, stride,
byteOffset);