Try fixes. draft
authorJeff Gilbert <jdashg@gmail.com>
Thu, 17 Dec 2015 16:16:53 -0800
changeset 316093 8d98a0c78d8991c670f19f991cb1da276a883027
parent 316092 0811d1510e91d32f4d20b19c3902708a4f293c6a
child 316094 29ed303d6ede7ce878e821a3c0c3959a9ee63e55
push id8514
push userjgilbert@mozilla.com
push dateFri, 18 Dec 2015 00:24:33 +0000
milestone45.0a1
Try fixes.
dom/canvas/WebGLContextFramebufferOperations.cpp
dom/canvas/WebGLFramebuffer.cpp
gfx/gl/GLContext.h
gfx/gl/GLContextProviderCGL.mm
--- a/dom/canvas/WebGLContextFramebufferOperations.cpp
+++ b/dom/canvas/WebGLContextFramebufferOperations.cpp
@@ -196,21 +196,26 @@ WebGLContext::DrawBuffers(const dom::Seq
         {
             ErrorInvalidOperation("%s: `buffers[i]` must be NONE or COLOR_ATTACHMENTi.",
                                   funcName);
             return;
         }
     }
 
     MakeContextCurrent();
-    gl->fDrawBuffers(buffers.Length(), buffers.Elements());
 
-    const GLenum* begin = buffers.Elements();
-    const GLenum* end = begin + buffers.Length();
-    mBoundDrawFramebuffer->mDrawBuffers.assign(begin, end);
+    const GLenum* ptr = nullptr;
+    if (buffers.Length()) {
+        ptr = buffers.Elements();
+    }
+
+    gl->fDrawBuffers(buffers.Length(), ptr);
+
+    const auto end = ptr + buffers.Length();
+    mBoundDrawFramebuffer->mDrawBuffers.assign(ptr, end);
 }
 
 void
 WebGLContext::StencilMask(GLuint mask)
 {
     if (IsContextLost())
         return;
 
--- a/dom/canvas/WebGLFramebuffer.cpp
+++ b/dom/canvas/WebGLFramebuffer.cpp
@@ -866,30 +866,38 @@ WebGLFramebuffer::CheckAndInitializeAtta
     {
         clearBits |= LOCAL_GL_STENCIL_BUFFER_BIT;
     }
 
     mContext->MakeContextCurrent();
 
     gl::GLContext* gl = mContext->gl;
 
-    const auto fnDrawBuffers = [gl](const std::vector<GLenum>& list) {
+    const auto fnDrawBuffers = [&gl](const std::vector<GLenum>& list) {
         const GLenum* ptr = nullptr;
         if (list.size()) {
             ptr = &(list[0]);
         }
         gl->fDrawBuffers(list.size(), ptr);
     };
 
-    fnDrawBuffers(tempDrawBuffers);
+    const auto drawBufferExt = WebGLExtensionID::WEBGL_draw_buffers;
+    const bool hasDrawBuffers = (mContext->IsWebGL2() ||
+                                 mContext->IsExtensionEnabled(drawBufferExt));
+
+    if (hasDrawBuffers) {
+        fnDrawBuffers(tempDrawBuffers);
+    }
 
     // Clear!
     mContext->ForceClearFramebufferWithDefaultValues(clearBits, false);
 
-    fnDrawBuffers(mDrawBuffers);
+    if (hasDrawBuffers) {
+        fnDrawBuffers(mDrawBuffers);
+    }
 
     // Mark all the uninitialized images as initialized.
     if (mDepthAttachment.HasUninitializedImageData())
         mDepthAttachment.SetImageDataStatus(WebGLImageDataStatus::InitializedImageData);
     if (mStencilAttachment.HasUninitializedImageData())
         mStencilAttachment.SetImageDataStatus(WebGLImageDataStatus::InitializedImageData);
     if (mDepthStencilAttachment.HasUninitializedImageData())
         mDepthStencilAttachment.SetImageDataStatus(WebGLImageDataStatus::InitializedImageData);
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -2308,16 +2308,17 @@ public:
     }
 
 
 // -----------------------------------------------------------------------------
 // Package XXX_draw_buffers
 public:
     void fDrawBuffers(GLsizei n, const GLenum* bufs) {
         BEFORE_GL_CALL;
+        ASSERT_SYMBOL_PRESENT(fDrawBuffers);
         mSymbols.fDrawBuffers(n, bufs);
         AFTER_GL_CALL;
     }
 
 
 // -----------------------------------------------------------------------------
 // Package XXX_draw_instanced
 public:
--- a/gfx/gl/GLContextProviderCGL.mm
+++ b/gfx/gl/GLContextProviderCGL.mm
@@ -109,16 +109,17 @@ bool
 GLContextCGL::MakeCurrentImpl(bool aForce)
 {
     if (!aForce && [NSOpenGLContext currentContext] == mContext) {
         return true;
     }
 
     if (mContext) {
         [mContext makeCurrentContext];
+        MOZ_ASSERT(IsCurrent());
         // Use non-blocking swap in "ASAP mode".
         // ASAP mode means that rendering is iterated as fast as possible.
         // ASAP mode is entered when layout.frame_rate=0 (requires restart).
         // If swapInt is 1, then glSwapBuffers will block and wait for a vblank signal.
         // When we're iterating as fast as possible, however, we want a non-blocking
         // glSwapBuffers, which will happen when swapInt==0.
         GLint swapInt = gfxPrefs::LayoutFrameRate() == 0 ? 0 : 1;
         [mContext setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];