Bug 1219494 - Part 3 gfx/gl with gfxCrash. r=mchang
authorMilan Sreckovic <milan@mozilla.com>
Thu, 10 Dec 2015 13:01:00 +0100
changeset 310325 9515714585ddefc107eb9b2199133eeec0d5bc86
parent 310324 279f56c0f49e9ebdf449c5fb26c3ce8fd8f05192
child 310326 f4f5472e714b85766dad38ec36ca4e3d2e685399
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmchang
bugs1219494
milestone45.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1219494 - Part 3 gfx/gl with gfxCrash. r=mchang
gfx/gl/GLBlitHelper.cpp
gfx/gl/GLContext.cpp
gfx/gl/GLContextProviderEGL.cpp
gfx/gl/GLLibraryEGL.cpp
gfx/gl/GLReadTexImageHelper.cpp
gfx/gl/GLScreenBuffer.cpp
gfx/gl/SharedSurface.cpp
gfx/gl/SharedSurfaceANGLE.cpp
--- a/gfx/gl/GLBlitHelper.cpp
+++ b/gfx/gl/GLBlitHelper.cpp
@@ -950,17 +950,17 @@ GLBlitHelper::DrawBlitTextureToFramebuff
     switch (srcTarget) {
     case LOCAL_GL_TEXTURE_2D:
         type = BlitTex2D;
         break;
     case LOCAL_GL_TEXTURE_RECTANGLE_ARB:
         type = BlitTexRect;
         break;
     default:
-        MOZ_CRASH("Fatal Error: Bad `srcTarget`.");
+        MOZ_CRASH("GFX: Fatal Error: Bad `srcTarget`.");
         break;
     }
 
     ScopedGLDrawState autoStates(mGL);
     if (internalFBs) {
         mGL->Screen()->BindFB_Internal(destFB);
     } else {
         mGL->BindFB(destFB);
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -2773,17 +2773,17 @@ GLContext::Readback(SharedSurface* src, 
                 fFramebufferTexture2D(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_COLOR_ATTACHMENT0,
                                       src->ProdTextureTarget(), src->ProdTexture(), 0);
                 break;
             case AttachmentType::GLRenderbuffer:
                 fFramebufferRenderbuffer(LOCAL_GL_FRAMEBUFFER, LOCAL_GL_COLOR_ATTACHMENT0,
                                          LOCAL_GL_RENDERBUFFER, src->ProdRenderbuffer());
                 break;
             default:
-                MOZ_CRASH("bad `src->mAttachType`.");
+                MOZ_CRASH("GFX: bad `src->mAttachType`.");
             }
 
             DebugOnly<GLenum> status = fCheckFramebufferStatus(LOCAL_GL_FRAMEBUFFER);
             MOZ_ASSERT(status == LOCAL_GL_FRAMEBUFFER_COMPLETE);
         }
 
         if (src->NeedsIndirectReads()) {
             fGenTextures(1, &tempTex);
--- a/gfx/gl/GLContextProviderEGL.cpp
+++ b/gfx/gl/GLContextProviderEGL.cpp
@@ -388,17 +388,17 @@ GLContextEGL::IsCurrent() {
 }
 
 bool
 GLContextEGL::RenewSurface() {
     if (!mOwnsContext) {
         return false;
     }
 #ifndef MOZ_WIDGET_ANDROID
-    MOZ_CRASH("unimplemented");
+    MOZ_CRASH("GFX: unimplemented");
     // to support this on non-Android platforms, need to keep track of the nsIWidget that
     // this GLContext was created for (with CreateForWindow) so that we know what to
     // pass again to CreateSurfaceForWindow below.
     // The reason why Android doesn't need this is that it delegates EGLSurface creation to
     // Java code which is the only thing that knows about our actual widget.
 #endif
     // unconditionally release the surface and create a new one. Don't try to optimize this away.
     // If we get here, then by definition we know that we want to get a new surface.
@@ -453,29 +453,29 @@ void
 GLContextEGL::HoldSurface(gfxASurface *aSurf) {
     mThebesSurface = aSurf;
 }
 
 /* static */ EGLSurface
 GLContextEGL::CreateSurfaceForWindow(nsIWidget* aWidget)
 {
     if (!sEGLLibrary.EnsureInitialized()) {
-        MOZ_CRASH("Failed to load EGL library!\n");
+        MOZ_CRASH("GFX: Failed to load EGL library!\n");
         return nullptr;
     }
 
     EGLConfig config;
     if (!CreateConfig(&config, aWidget)) {
-        MOZ_CRASH("Failed to create EGLConfig!\n");
+        MOZ_CRASH("GFX: Failed to create EGLConfig!\n");
         return nullptr;
     }
 
     EGLSurface surface = mozilla::gl::CreateSurfaceForWindow(aWidget, config);
     if (!surface) {
-        MOZ_CRASH("Failed to create EGLSurface for window!\n");
+        MOZ_CRASH("GFX: Failed to create EGLSurface for window!\n");
         return nullptr;
     }
     return surface;
 }
 
 /* static */ void
 GLContextEGL::DestroySurface(EGLSurface aSurface)
 {
@@ -736,17 +736,17 @@ CreateConfig(EGLConfig* aConfig, nsIWidg
         return true;
     }
 }
 
 already_AddRefed<GLContext>
 GLContextProviderEGL::CreateWrappingExisting(void* aContext, void* aSurface)
 {
     if (!sEGLLibrary.EnsureInitialized()) {
-        MOZ_CRASH("Failed to load EGL library!\n");
+        MOZ_CRASH("GFX: Failed to load EGL library 2!\n");
         return nullptr;
     }
 
     if (aContext && aSurface) {
         SurfaceCaps caps = SurfaceCaps::Any();
         EGLConfig config = EGL_NO_CONFIG;
         RefPtr<GLContextEGL> glContext =
             new GLContextEGL(caps,
@@ -761,81 +761,81 @@ GLContextProviderEGL::CreateWrappingExis
 
     return nullptr;
 }
 
 already_AddRefed<GLContext>
 GLContextProviderEGL::CreateForWindow(nsIWidget *aWidget)
 {
     if (!sEGLLibrary.EnsureInitialized()) {
-        MOZ_CRASH("Failed to load EGL library!\n");
+        MOZ_CRASH("GFX: Failed to load EGL library 3!\n");
         return nullptr;
     }
 
     bool doubleBuffered = true;
 
     EGLConfig config;
     if (!CreateConfig(&config, aWidget)) {
-        MOZ_CRASH("Failed to create EGLConfig!\n");
+        MOZ_CRASH("GFX: Failed to create EGLConfig!\n");
         return nullptr;
     }
 
     EGLSurface surface = mozilla::gl::CreateSurfaceForWindow(aWidget, config);
     if (!surface) {
-        MOZ_CRASH("Failed to create EGLSurface!\n");
+        MOZ_CRASH("GFX: Failed to create EGLSurface!\n");
         return nullptr;
     }
 
     SurfaceCaps caps = SurfaceCaps::Any();
     RefPtr<GLContextEGL> glContext =
         GLContextEGL::CreateGLContext(CreateContextFlags::NONE, caps,
                                       nullptr, false,
                                       config, surface);
 
     if (!glContext) {
-        MOZ_CRASH("Failed to create EGLContext!\n");
+        MOZ_CRASH("GFX: Failed to create EGLContext!\n");
         mozilla::gl::DestroySurface(surface);
         return nullptr;
     }
 
     glContext->MakeCurrent();
     glContext->SetIsDoubleBuffered(doubleBuffered);
 
     return glContext.forget();
 }
 
 #if defined(ANDROID)
 EGLSurface
 GLContextProviderEGL::CreateEGLSurface(void* aWindow)
 {
     if (!sEGLLibrary.EnsureInitialized()) {
-        MOZ_CRASH("Failed to load EGL library!\n");
+        MOZ_CRASH("GFX: Failed to load EGL library 4!\n");
     }
 
     EGLConfig config;
     if (!CreateConfig(&config, static_cast<nsIWidget*>(aWindow))) {
-        MOZ_CRASH("Failed to create EGLConfig!\n");
+        MOZ_CRASH("GFX: Failed to create EGLConfig 2!\n");
     }
 
     MOZ_ASSERT(aWindow);
 
     EGLSurface surface = sEGLLibrary.fCreateWindowSurface(EGL_DISPLAY(), config, aWindow, 0);
 
     if (surface == EGL_NO_SURFACE) {
-        MOZ_CRASH("Failed to create EGLSurface!\n");
+        MOZ_CRASH("GFX: Failed to create EGLSurface 2!\n");
     }
 
     return surface;
 }
 
 void
 GLContextProviderEGL::DestroyEGLSurface(EGLSurface surface)
 {
     if (!sEGLLibrary.EnsureInitialized()) {
-        MOZ_CRASH("Failed to load EGL library!\n");
+        MOZ_CRASH("GFX: Failed to load EGL library 5!\n");
     }
 
     sEGLLibrary.fDestroySurface(EGL_DISPLAY(), surface);
 }
 #endif // defined(ANDROID)
 
 static void
 FillContextAttribs(bool alpha, bool depth, bool stencil, bool bpp16,
--- a/gfx/gl/GLLibraryEGL.cpp
+++ b/gfx/gl/GLLibraryEGL.cpp
@@ -184,17 +184,17 @@ GLLibraryEGL::EnsureInitialized(bool for
     if (mInitialized) {
         return true;
     }
 
     mozilla::ScopedGfxFeatureReporter reporter("EGL");
 
 #ifdef MOZ_B2G
     if (!sCurrentContext.init())
-      MOZ_CRASH("Tls init failed");
+      MOZ_CRASH("GFX: Tls init failed");
 #endif
 
 #ifdef XP_WIN
     if (!mEGLLibrary) {
         // On Windows, the GLESv2, EGL and DXSDK libraries are shipped with libxul and
         // we should look for them there. We have to load the libs in this
         // order, because libEGL.dll depends on libGLESv2.dll which depends on the DXSDK
         // libraries. This matters especially for WebRT apps which are in a different directory.
--- a/gfx/gl/GLReadTexImageHelper.cpp
+++ b/gfx/gl/GLReadTexImageHelper.cpp
@@ -394,17 +394,17 @@ ReadPixelsIntoDataSurface(GLContext* gl,
         destFormat = LOCAL_GL_RGBA;
         destType = LOCAL_GL_UNSIGNED_BYTE;
         break;
     case SurfaceFormat::R5G6B5_UINT16:
         destFormat = LOCAL_GL_RGB;
         destType = LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV;
         break;
     default:
-        MOZ_CRASH("Bad format.");
+        MOZ_CRASH("GFX: Bad format, read pixels.");
     }
     destPixelSize = BytesPerPixel(dest->GetFormat());
     MOZ_ASSERT(dest->GetSize().width * destPixelSize <= dest->Stride());
 
     GLenum readFormat = destFormat;
     GLenum readType = destType;
     bool needsTempSurf = !GetActualReadFormats(gl,
                                                destFormat, destType,
@@ -437,17 +437,17 @@ ReadPixelsIntoDataSurface(GLContext* gl,
             }
             case LOCAL_GL_RGB: {
                 MOZ_ASSERT(destPixelSize == 2);
                 MOZ_ASSERT(readType == LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV);
                 readFormatGFX = SurfaceFormat::R5G6B5_UINT16;
                 break;
             }
             default: {
-                MOZ_CRASH("Bad read format.");
+                MOZ_CRASH("GFX: Bad read format, read format.");
             }
         }
 
         switch (readType) {
             case LOCAL_GL_UNSIGNED_BYTE: {
                 MOZ_ASSERT(readFormat == LOCAL_GL_RGBA);
                 readAlignment = 1;
                 break;
@@ -458,17 +458,17 @@ ReadPixelsIntoDataSurface(GLContext* gl,
                 break;
             }
             case LOCAL_GL_UNSIGNED_SHORT_5_6_5_REV: {
                 MOZ_ASSERT(readFormat == LOCAL_GL_RGB);
                 readAlignment = 2;
                 break;
             }
             default: {
-                MOZ_CRASH("Bad read type.");
+                MOZ_CRASH("GFX: Bad read type, read type.");
             }
         }
 
         int32_t stride = dest->GetSize().width * BytesPerPixel(readFormatGFX);
         tempSurf = Factory::CreateDataSourceSurfaceWithStride(dest->GetSize(),
                                                               readFormatGFX,
                                                               stride);
         if (NS_WARN_IF(!tempSurf)) {
--- a/gfx/gl/GLScreenBuffer.cpp
+++ b/gfx/gl/GLScreenBuffer.cpp
@@ -167,17 +167,17 @@ GLScreenBuffer::BindAsFramebuffer(GLCont
         gl->raw_fBindFramebuffer(LOCAL_GL_DRAW_FRAMEBUFFER_EXT, drawFB);
         break;
 
     case LOCAL_GL_READ_FRAMEBUFFER_EXT:
         gl->raw_fBindFramebuffer(LOCAL_GL_READ_FRAMEBUFFER_EXT, readFB);
         break;
 
     default:
-        MOZ_CRASH("Bad `target` for BindFramebuffer.");
+        MOZ_CRASH("GFX: Bad `target` for BindFramebuffer.");
     }
 }
 
 void
 GLScreenBuffer::BindFB(GLuint fb)
 {
     GLuint drawFB = DrawFB();
     GLuint readFB = ReadFB();
@@ -438,17 +438,17 @@ GLScreenBuffer::AssureBlitted()
 
             mGL->raw_fBlitFramebuffer(0, 0,  srcSize.width,  srcSize.height,
                                       0, 0, destSize.width, destSize.height,
                                       LOCAL_GL_COLOR_BUFFER_BIT,
                                       LOCAL_GL_NEAREST);
         } else if (mGL->IsExtensionSupported(GLContext::APPLE_framebuffer_multisample)) {
             mGL->fResolveMultisampleFramebufferAPPLE();
         } else {
-            MOZ_CRASH("No available blit methods.");
+            MOZ_CRASH("GFX: No available blit methods.");
         }
         // Done!
     }
 
     mNeedsBlit = false;
 }
 
 void
@@ -652,17 +652,17 @@ GLScreenBuffer::SetDrawBuffer(GLenum mod
                                  : LOCAL_GL_COLOR_ATTACHMENT0;
         break;
 
     case LOCAL_GL_NONE:
         internalMode = LOCAL_GL_NONE;
         break;
 
     default:
-        MOZ_CRASH("Bad value.");
+        MOZ_CRASH("GFX: Bad value.");
     }
 
     mGL->MakeCurrent();
     mGL->fDrawBuffers(1, &internalMode);
 }
 
 void
 GLScreenBuffer::SetReadBuffer(GLenum mode)
@@ -889,17 +889,17 @@ ReadBuffer::Create(GLContext* gl,
     case AttachmentType::GLTexture:
         colorTex = surf->ProdTexture();
         target = surf->ProdTextureTarget();
         break;
     case AttachmentType::GLRenderbuffer:
         colorRB = surf->ProdRenderbuffer();
         break;
     default:
-        MOZ_CRASH("Unknown attachment type?");
+        MOZ_CRASH("GFX: Unknown attachment type, create?");
     }
     MOZ_ASSERT(colorTex || colorRB);
 
     GLuint fb = 0;
     gl->fGenFramebuffers(1, &fb);
     gl->AttachBuffersToFB(colorTex, colorRB, depthRB, stencilRB, fb, target);
     gl->mFBOMapping[fb] = surf;
 
@@ -947,17 +947,17 @@ ReadBuffer::Attach(SharedSurface* surf)
         case AttachmentType::GLTexture:
             colorTex = surf->ProdTexture();
             target = surf->ProdTextureTarget();
             break;
         case AttachmentType::GLRenderbuffer:
             colorRB = surf->ProdRenderbuffer();
             break;
         default:
-            MOZ_CRASH("Unknown attachment type?");
+            MOZ_CRASH("GFX: Unknown attachment type, attach?");
         }
 
         mGL->AttachBuffersToFB(colorTex, colorRB, 0, 0, mFB, target);
         mGL->mFBOMapping[mFB] = surf;
         MOZ_ASSERT(mGL->IsFramebufferComplete(mFB));
     }
 
     mSurf = surf;
@@ -984,17 +984,17 @@ ReadBuffer::SetReadBuffer(GLenum userMod
                                   : LOCAL_GL_COLOR_ATTACHMENT0;
         break;
 
     case LOCAL_GL_NONE:
         internalMode = LOCAL_GL_NONE;
         break;
 
     default:
-        MOZ_CRASH("Bad value.");
+        MOZ_CRASH("GFX: Bad value.");
     }
 
     mGL->MakeCurrent();
     mGL->fReadBuffer(internalMode);
 }
 
 } /* namespace gl */
 } /* namespace mozilla */
--- a/gfx/gl/SharedSurface.cpp
+++ b/gfx/gl/SharedSurface.cpp
@@ -73,17 +73,17 @@ SharedSurface::ProdCopy(SharedSurface* s
             ScopedFramebufferForRenderbuffer destWrapper(gl, destRB);
 
             gl->BlitHelper()->BlitFramebufferToFramebuffer(0,
                                                            destWrapper.FB(),
                                                            src->mSize,
                                                            dest->mSize,
                                                            true);
         } else {
-            MOZ_CRASH("Unhandled dest->mAttachType.");
+            MOZ_CRASH("GFX: Unhandled dest->mAttachType 1.");
         }
 
         if (srcNeedsUnlock)
             src->UnlockProd();
 
         if (origNeedsRelock)
             origLocked->LockProd();
 
@@ -118,17 +118,17 @@ SharedSurface::ProdCopy(SharedSurface* s
             ScopedFramebufferForRenderbuffer srcWrapper(gl, srcRB);
 
             gl->BlitHelper()->BlitFramebufferToFramebuffer(srcWrapper.FB(),
                                                            0,
                                                            src->mSize,
                                                            dest->mSize,
                                                            true);
         } else {
-            MOZ_CRASH("Unhandled src->mAttachType.");
+            MOZ_CRASH("GFX: Unhandled src->mAttachType 2.");
         }
 
         if (destNeedsUnlock)
             dest->UnlockProd();
 
         if (origNeedsRelock)
             origLocked->LockProd();
 
@@ -158,17 +158,17 @@ SharedSurface::ProdCopy(SharedSurface* s
             ScopedFramebufferForRenderbuffer destWrapper(gl, destRB);
 
             gl->BlitHelper()->BlitTextureToFramebuffer(srcTex, destWrapper.FB(),
                                                        src->mSize, dest->mSize, srcTarget);
 
             return;
         }
 
-        MOZ_CRASH("Unhandled dest->mAttachType.");
+        MOZ_CRASH("GFX: Unhandled dest->mAttachType 3.");
     }
 
     if (src->mAttachType == AttachmentType::GLRenderbuffer) {
         GLuint srcRB = src->ProdRenderbuffer();
         ScopedFramebufferForRenderbuffer srcWrapper(gl, srcRB);
 
         if (dest->mAttachType == AttachmentType::GLTexture) {
             GLuint destTex = dest->ProdTexture();
@@ -185,20 +185,20 @@ SharedSurface::ProdCopy(SharedSurface* s
             ScopedFramebufferForRenderbuffer destWrapper(gl, destRB);
 
             gl->BlitHelper()->BlitFramebufferToFramebuffer(srcWrapper.FB(), destWrapper.FB(),
                                                            src->mSize, dest->mSize);
 
             return;
         }
 
-        MOZ_CRASH("Unhandled dest->mAttachType.");
+        MOZ_CRASH("GFX: Unhandled dest->mAttachType 4.");
     }
 
-    MOZ_CRASH("Unhandled src->mAttachType.");
+    MOZ_CRASH("GFX: Unhandled src->mAttachType 5.");
 }
 
 ////////////////////////////////////////////////////////////////////////
 // SharedSurface
 
 
 SharedSurface::SharedSurface(SharedSurfaceType type,
                              AttachmentType attachType,
@@ -465,17 +465,17 @@ ScopedReadbackFB::ScopedReadbackFB(Share
 
             // TODO: This should just be BindFB, but we don't have
             // the patch for this yet. (bug 1045955)
             MOZ_ASSERT(mGL->Screen());
             mGL->Screen()->BindReadFB_Internal(0);
             break;
         }
     default:
-        MOZ_CRASH("Unhandled `mAttachType`.");
+        MOZ_CRASH("GFX: Unhandled `mAttachType`.");
     }
 
     if (src->NeedsIndirectReads()) {
         mGL->fGenTextures(1, &mTempTex);
 
         {
             ScopedBindTexture autoTex(mGL, mTempTex);
 
--- a/gfx/gl/SharedSurfaceANGLE.cpp
+++ b/gfx/gl/SharedSurfaceANGLE.cpp
@@ -153,17 +153,17 @@ SharedSurface_ANGLEShareHandle::PollSync
 }
 
 void
 SharedSurface_ANGLEShareHandle::ProducerAcquireImpl()
 {
     if (mKeyedMutex) {
         HRESULT hr = mKeyedMutex->AcquireSync(0, 10000);
         if (hr == WAIT_TIMEOUT) {
-            MOZ_CRASH();
+            MOZ_CRASH("GFX: ANGLE share handle timeout");
         }
     }
 }
 
 void
 SharedSurface_ANGLEShareHandle::ProducerReleaseImpl()
 {
     if (mKeyedMutex) {
@@ -209,17 +209,17 @@ SharedSurface_ANGLEShareHandle::Consumer
                 mConsumerKeyedMutex = mutex;
             }
         }
     }
 
     if (mConsumerKeyedMutex) {
       HRESULT hr = mConsumerKeyedMutex->AcquireSync(0, 10000);
       if (hr == WAIT_TIMEOUT) {
-        MOZ_CRASH();
+        MOZ_CRASH("GFX: ANGLE consumer mutex timeout");
       }
     }
 }
 
 void
 SharedSurface_ANGLEShareHandle::ConsumerReleaseImpl()
 {
     if (mConsumerKeyedMutex) {
@@ -284,17 +284,17 @@ public:
         MOZ_ASSERT(succeeded);
         *succeeded = false;
 
         HRESULT hr;
         mTexture->QueryInterface((IDXGIKeyedMutex**)getter_AddRefs(mMutex));
         if (mMutex) {
             hr = mMutex->AcquireSync(0, 10000);
             if (hr == WAIT_TIMEOUT) {
-                MOZ_CRASH();
+                MOZ_CRASH("GFX: ANGLE scoped lock timeout");
             }
 
             if (FAILED(hr)) {
                 NS_WARNING("Failed to lock the texture");
                 return;
             }
         }