Bug 1300946 - GetCurrentBinding is the wrong approach. - r=jrmuizel a=ritu
authorJeff Gilbert <jgilbert@mozilla.com>
Wed, 07 Sep 2016 15:27:20 -0700
changeset 355843 37e1580285cec8ff166e3949e4fffe16a37d5349
parent 355842 73efde7745eee1e2d28d35e2cf6461f4844bc014
child 355844 92905db1d7e3c99dda2aa21c00b7d8908f742f84
push id6570
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:26:13 +0000
treeherdermozilla-beta@f455459b2ae5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel, ritu
bugs1300946
milestone51.0a2
Bug 1300946 - GetCurrentBinding is the wrong approach. - r=jrmuizel a=ritu MozReview-Commit-ID: 866FkuUMMob
dom/canvas/WebGLContext.h
dom/canvas/WebGLContextBuffers.cpp
--- a/dom/canvas/WebGLContext.h
+++ b/dom/canvas/WebGLContext.h
@@ -777,18 +777,16 @@ protected:
 
     nsTArray<WebGLRefPtr<WebGLBuffer>> mBoundUniformBuffers;
     nsTArray<WebGLRefPtr<WebGLBuffer>> mBoundTransformFeedbackBuffers;
 
     WebGLRefPtr<WebGLBuffer>& GetBufferSlotByTarget(GLenum target);
     WebGLRefPtr<WebGLBuffer>& GetBufferSlotByTargetIndexed(GLenum target,
                                                            GLuint index);
 
-    GLenum GetCurrentBinding(WebGLBuffer* buffer) const;
-
 // -----------------------------------------------------------------------------
 // Queries (WebGL2ContextQueries.cpp)
 protected:
     WebGLRefPtr<WebGLQuery>& GetQuerySlotByTarget(GLenum target);
 
     WebGLRefPtr<WebGLQuery> mActiveOcclusionQuery;
     WebGLRefPtr<WebGLQuery> mActiveTransformFeedbackQuery;
 
--- a/dom/canvas/WebGLContextBuffers.cpp
+++ b/dom/canvas/WebGLContextBuffers.cpp
@@ -229,17 +229,17 @@ WebGLContext::BufferDataT(GLenum target,
     }
 
     boundBuffer->SetByteLength(data.LengthAllowShared());
 
     // Warning: Possibly shared memory.  See bug 1225033.
     if (!boundBuffer->ElementArrayCacheBufferData(data.DataAllowShared(), data.LengthAllowShared())) {
         boundBuffer->SetByteLength(0);
         return ErrorOutOfMemory("bufferData: out of memory");
-	}
+    }
 }
 
 void
 WebGLContext::BufferData(GLenum target,
                          const dom::SharedArrayBuffer& data,
                          GLenum usage)
 {
     BufferDataT(target, data, usage);
@@ -460,34 +460,16 @@ WebGLContext::ValidateBufferForTarget(GL
      * Any call to one of these functions which attempts to bind a
      * WebGLBuffer that has the element array WebGL buffer type to a
      * binding point that falls under other data, or bind a
      * WebGLBuffer which has the other data WebGL buffer type to
      * ELEMENT_ARRAY_BUFFER will generate an INVALID_OPERATION error,
      * and the state of the binding point will remain untouched.
      */
 
-    GLenum boundTo = GetCurrentBinding(buffer);
-    if (boundTo != LOCAL_GL_NONE) {
-        if (target == LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER &&
-            boundTo != LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER)
-        {
-            ErrorInvalidOperation("Can't bind buffer to TRANSFORM_FEEDBACK_BUFFER as the "
-                                  "buffer is already bound to another bind point.");
-            return false;
-        }
-        else if (target != LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER &&
-                 boundTo == LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER)
-        {
-            ErrorInvalidOperation("Can't bind buffer to bind point as it is currently "
-                                  "bound to TRANSFORM_FEEDBACK_BUFFER.");
-            return false;
-        }
-    }
-
     WebGLBuffer::Kind content = buffer->Content();
     if (content == WebGLBuffer::Kind::Undefined)
         return true;
 
     switch (target) {
     case LOCAL_GL_COPY_READ_BUFFER:
     case LOCAL_GL_COPY_WRITE_BUFFER:
         return true;
@@ -582,47 +564,16 @@ WebGLContext::GetBufferSlotByTargetIndex
         return mBoundUniformBuffers[index];
 
     default:
         MOZ_CRASH("GFX: Should not get here.");
     }
 }
 
 GLenum
-WebGLContext::GetCurrentBinding(WebGLBuffer* buffer) const
-{
-    if (mBoundArrayBuffer == buffer)
-        return LOCAL_GL_ARRAY_BUFFER;
-
-    if (mBoundCopyReadBuffer == buffer)
-        return LOCAL_GL_COPY_READ_BUFFER;
-
-    if (mBoundCopyWriteBuffer == buffer)
-        return LOCAL_GL_COPY_WRITE_BUFFER;
-
-    if (mBoundPixelPackBuffer == buffer)
-        return LOCAL_GL_PIXEL_PACK_BUFFER;
-
-    if (mBoundPixelUnpackBuffer == buffer)
-        return LOCAL_GL_PIXEL_UNPACK_BUFFER;
-
-    if (mBoundTransformFeedbackBuffer == buffer ||
-        mBoundTransformFeedbackBuffers.Contains(buffer)) {
-        return LOCAL_GL_TRANSFORM_FEEDBACK_BUFFER;
-    }
-
-    if (mBoundUniformBuffer == buffer ||
-        mBoundUniformBuffers.Contains(buffer)) {
-        return LOCAL_GL_UNIFORM_BUFFER;
-    }
-
-    return LOCAL_GL_NONE;
-}
-
-GLenum
 WebGLContext::CheckedBufferData(GLenum target, GLsizeiptr size,
                                 const GLvoid* data, GLenum usage)
 {
 #ifdef XP_MACOSX
     // bug 790879
     if (gl->WorkAroundDriverBugs() &&
         int64_t(size) > INT32_MAX) // cast avoids a potential always-true warning on 32bit
     {