Bug 1326517 - Allow clearing to null with VertexAttribPointer. - r=kvark draft
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 30 Dec 2016 20:43:24 -0800
changeset 454999 f2b7b35332b7013c9ea30c3e352e126232ab877f
parent 454949 e120594f18fb68bf0cc9fe119100210f8b4a354c
child 540870 a6e066d997919300fe0e356cc415e632661680c8
push id40109
push userbmo:jgilbert@mozilla.com
push dateSat, 31 Dec 2016 04:53:19 +0000
reviewerskvark
bugs1326517
milestone53.0a1
Bug 1326517 - Allow clearing to null with VertexAttribPointer. - r=kvark MozReview-Commit-ID: Ai5ksUAyG4q
dom/canvas/WebGLContextValidate.cpp
dom/canvas/WebGLContextVertices.cpp
--- 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);